Given the fallowing array $array:
Array
(
[1] => Array
(
[0] => 267
[location_id_keep] => 261
)
[2] => Array
(
[0] => 266
[location_id_keep] => 262
)
[3] => Array
(
[0] => 2669
[1] => 2670
[location_id_keep] => 2668
)
[4] => Array
(
[0] => 266
[1] => 2670
[location_id_keep] => 2668
)
)
I want to add to the each arrays values that doesn't have the [location_id_keep] key the fallowing key: [location_id_delete] so that I will get this output:
Array
(
[1] => Array
(
[location_id_delete] => 267
[location_id_keep] => 261
)
[2] => Array
(
[location_id_delete] => 266
[location_id_keep] => 262
)
[3] => Array
(
[location_id_delete] => [2669, 2670]
[location_id_keep] => 2668
)
[4] => Array
(
[location_id_delete] => [266, 2670]
[location_id_keep] => 2668
)
)
Is there any method to add keys inside array assigned to already existing values that doesn't have a key ?
location_id_delete?[location_id_delete] => 2669 [location_id_delete] => 2670should be,for example,[location_id_delete] => [2669,2670]