I think my problem is simple to solve but for the life of me I can't figure it out.
I need to convert this multi dimensional 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
)
)
Into this:
[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 have tried using foreach loops but I can not 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 a phpfiddle I need to convert the $locationsBAD array into looking like the $locationsGOOD array