Im a bit lost or mind is not working as it should. I read other questions around but can get mine to work.
I got this array:
Array
(
[89] => Array
(
[0] => 16
[1] => 2
)
)
And i got this :
Array
(
[84] => Array
(
[0] => 2
)
[83] => Array
(
[0] => 2
)
[87] => Array
(
[0] => 2
[1] => 3
)
[88] => Array
(
[0] => 2
)
[89] => Array
(
[0] => 2
)
[90] => Array
(
[0] => 2
)
)
I should get all results but on key 89 i should get the value from first array.
Array
(
[84] => Array
(
[0] => 2
)
[83] => Array
(
[0] => 2
)
[87] => Array
(
[0] => 2
[1] => 3
)
[88] => Array
(
[0] => 2
)
[89] => Array
(
[0] => 16
[1] => 2
)
[90] => Array
(
[0] => 2
)
)
Array merge wont work 🙁 .
Also after i get the result if the first array its :
Array
(
[89] => Array
(
[1] => 2
)
)
The resulting array should update to one record.
Im sure its a 1 min code for you gurus but arrays always been a pain for me.
Thanks
UPDATE : if i use array_merge_recursive it wont keep my keys :
print_r(array_merge_recursive($array1,$array2));
Array
(
[0] => Array
(
[0] => 16
[1] => 2
)
[1] => Array
(
[0] => 2
)
[2] => Array
(
[0] => 2
)
[3] => Array
(
[0] => 2
[1] => 3
)
[4] => Array
(
[0] => 2
)
[5] => Array
(
[0] => 2
)
[6] => Array
(
[0] => 2
)
)
array_merge_recursiveshould do the job; look at the documentation for more pointers: http://www.php.net/manual/en/function.array-merge-recursive.phpEDIT
The function behaved differently than I initially thought, here´s a different version of the function to solve your problem:
Thanks to the community of php.net http://www.php.net/manual/en/function.array-merge-recursive.php#92195