I think that my problem is easy to solve, but for life I can not understand.
I need to convert this multidimensional array:
[additionallocations] => Array
(
[Address] => Array
(
[0] => Address1
[1] => Address2
)
[City] => Array
(
[0] => City1
[1] => City2
)
[State] => Array
(
[0] => AK
[1] => DC
)
[Zip] => Array
(
[0] => 234423
[1] => 32423
)
[Country] => Array
(
[0] => US
[1] => US
)
)
In it:
[additionallocations0] => Array
(
[Address] => Address1
[City] => City1
[State] => AK
[Zip] => 234423
[Country] => US
)
[additionallocations1] => Array
(
[Address] => Address2
[City] => City2
[State] => DC
[Zip] => 32423
[Country] => US
)
I tried using foreach loops, but I cannot get the expected results:
$count = 0;
foreach($_POST['additionallocations'] as $value => $key) {
foreach($key as $row) {
$additional['additional'.$count] = array($value => $row);
}
$count++;
}
Here is phpfiddle I need to convert an array $locationsBADas an array$locationsGOOD
source
share