I have a result array like this:
$result = Array
(
[1] => Array
(
[0] => some value
[1] => some value
[2] => some value
)
[4] => Array
(
[0] => some value
[1] => some value
[6] => Array
(
[0] => some value
[8] => Array
(
[0] => some value
)
)
)
)
and I have a second array
$test = Array
(
[4] => Array
(
[6] => Array
(
[8] => Array
(
[0] = value to add
)
)
)
)
How can I update the $result
array on base of keys from $test
array without losing any key index. The main point is $result
can have any structure and is dynamically generated but the $test
array will always have keys index(s) which will somewhat match the $result
array. The general PHP array combine merge and other functions don't provide desired results.
[Edit] The point is my second array $test will decide the position of $result where the data will be added/merged.
Did you try using: http://php.net/manual/en/function.array-merge-recursive.php
By add do you mean append or addition(sum)?? This should work for appending the data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.