Search
 
SCRIPT & CODE EXAMPLE
 

PHP

array flat php

$c = ["a" => ["x" => "X", "y" => "Y"], "b" => ["p" => "P", "q" => "Q"]];
print_r(array_merge(...array_values($c)));

Array
(
    [x] => X
    [y] => Y
    [p] => P
    [q] => Q
)
Comment

array_flatten php

/**
 * Function converts multidimentional array to a plain one
 *
 * @param $arr multidimensional array
 *
 * @return array
 */
function array_flatten($arr) {
    $return = [];
    foreach ($arr as $key => $value) {
        if (is_array($value)) {
            $return = array_merge($return, array_flatten($value));
        } else {
            $return[] = $value;
        }
    }
    return $return;
}
Comment

php flatten array

array_merge(...$a);
Comment

flatten in array php

array_merge(...$a);
Comment

flatten in array php

array_merge([], ...$a);
Comment

array flat php

$a = [[10, 20], [30, 40]];
$b = [["x" => "X", "y" => "Y"], ["p" => "P", "q" => "Q"]];

print_r(array_merge(...$a));
print_r(array_merge(...$b));

Array
(
    [0] => 10
    [1] => 20
    [2] => 30
    [3] => 40
)
Array
(
    [x] => X
    [y] => Y
    [p] => P
    [q] => Q
)
Comment

PREVIOUS NEXT
Code Example
Php :: check if the link is image or url php 
Php :: change arabic number to english php 
Php :: wordpress Warning: Cannot modify header information - headers already sent by 
Php :: laravel collection pluck 
Php :: php nginx file not found 
Php :: laravel web php request to redirect to another page 
Php :: php replace youtube embed url 
Php :: wordpress get user profile picture 
Php :: how to use php to print inside html 
Php :: create a new project from cli laravel 
Php :: date in php 
Php :: drupal 8 get enabled languages 
Php :: php strict mode 
Php :: laravel api response json 
Php :: laravel eloquent group by week 
Php :: laravel eloquent many to many query using whereHas 
Php :: php new object 
Php :: create controller with model resources and request command in laravel 
Php :: wp-config for developement 
Php :: php formData curl 
Php :: woocommerce get orders by user id 
Php :: hide all error in php 
Php :: php camelcase to snake case 
Php :: json encode decode php 
Php :: php remove first word from string 
Php :: PHP Display Posts by Category in WordPress 
Php :: Php get all timezone 
Php :: php number to words 
Php :: laravel value eloquent 
Php :: show woocommerce product variation in table php 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =