PHP convert multidimensional array to one array using function Flatten
PHP convert multidimensional array to one array using function Flatten.
Chuyển 1 mảng nhiều giá trị thành 1 mảng
private function arrayFlatten($array) {
$result = array();
if (!is_array($array)) {
$array = func_get_args();
}
foreach ($array as $key => $value) {
if (is_array($value)) {
$result = array_merge($result, $this->arrayFlatten($value));
} else {
$result = array_merge($result, array($key => $value));
}
}
return $result;
}
$source = [1, [2], [[3], 4], 5]; // [1, 2, [3], 4, 5];
$source = [1, [2], [[3], 4], 5]; // [1, 2, 3, 4, 5];
Tin tức khác
- Laravel updateOrCreate lấy trạng thái insert or update
- Lazy load cho Google tag manager tăng tốc trên PageSpeed
- Wordpress 5 phân trang - wordpress 5 pagination
- PHP So sánh thời gian hơn 24h
- PHP multidimensional array search by key value array
- Php export data to excel 2007 xlsx
- Htaccess redirect http to https
-
Php replace img tab to amp-img26-03-2017
-
Php convert multi array to one array27-04-2017
-
CSS text-decoration: line-through13-04-2017
-
Php glob quét tìm file31-03-2017
-
Tạo file tạm và upload nó bằng FTP php27-03-2017
-
PHP So sánh thời gian hơn 24h10-07-2021
Tin tức liên quan
Video News

Cẩm Loan - Tuyển tập những ca khúc Miền Tây
05-07-2019 7945

List nhạc hay tháng 3/2018
12-03-2018 7600

Liên khúc sến nhảy
22-06-2017 8517
Danh Mục
Liên hệ
Cảm ơn bạn đã liên hệ. Nhân viên chúng tôi sẽ liên hệ với bạn trong thời gian sớm nhất.
© Copyright 2023. Thiết kế website bởi Fdola.com