multivalue array to single value php code example
Example 1: convert multidimensional array to single array php
$singleArray = [];
foreach ($parentArray as $childArray)
{
foreach ($childArray as $value)
{
$singleArray[] = $value;
}
}
Example 2: 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
)