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 :: How to check if email exists in laravel validaton 
Php :: json_encode() in php 
Php :: What does PEAR stands for? 
Php :: ajax post json data handle in php 
Php :: laravel handle queryexception 
Php :: Remove public from the url in the codeigniter 
Php :: laravel list of tables 
Php :: web api return json example in php 
Php :: laravel create db 
Php :: laravel truncate string laravel 8 
Php :: subtract string php 
Php :: is dir php 
Php :: wordpress logout 
Php :: register sidebar wordpress 
Php :: php group array by value and count 
Php :: php header redirect with parameters 
Php :: Notice: Undefined variable: _SESSION in C:xampphtdocspracticeheader.php on line 7 
Php :: next year php string 
Php :: laravel update return updated row, laravel update return 
Php :: PHP utf8_encode — Converts a string from ISO-8859-1 to UTF-8 
Php :: export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH 
Php :: create symbolic in lumen laravel 
Php :: php continue 
Php :: insert data using seeder in laravel 
Php :: php day of week full name 
Php :: php echo variable 
Php :: resource controller artisan command 
Php :: wordpress 404.php redirect to home 
Php :: wordpress add new page programmatically 
Php :: php datetime add 1 weeek 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =