Answers for "php flatten array"

PHP
0

php flatten multidimensional array

<?php

$notFlat = [[1,2],[3,4]];
$flat = array_merge(...$notFlat);
var_dump($flat);
Posted by: Guest on October-30-2020
-1

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
)
Posted by: Guest on October-23-2020
0

php flatten array

array_merge(...$a);
Posted by: Guest on July-15-2021
-1

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
)
Posted by: Guest on October-23-2020

Browse Popular Code Answers by Language