I have two arrays both guaranteed to be the same length. The two arrays are of the following structures
array1
Array
(
[0] => Array
(
[id] => 841052
[store] => 11
[position] => 1
)
[1] => Array
(
[id] => 1613197
[store] => 11
[position] => 401
)
[2] => Array
(
[id] => 1648966
[store] => 11
[position] => 1
)
[3] => Array
(
[id] => 1656857
[store] => 11
[position] => 1
)
....
....
)
array2
Array
(
[0] => 5/20/2019
[1] => 7/7/2019
[2] => 12/16/2018
...
...
)
How do I append every value of array2 as a key value pair to array1 to get the following array. The key name can be whatever I just chose date.
Array
(
[0] => Array
(
[id] => 841052
[store] => 11
[position] => 1
[date] => 5/20/2019
)
[1] => Array
(
[id] => 1613197
[store] => 11
[position] => 401
[date] => 7/7/2019
)
[2] => Array
(
[id] => 1648966
[store] => 11
[position] => 1
[date] => 12/16/2018
)
)
...
...
...
I have tried
array_push($array1, $array2);
It just pushed it to the last element of the array. I thought of using two foreach loops but couldn't get ti to work. Is there a built in php function that will do this, or do I have to do it in loops.