Msg#: 3914527 posted 4:59 pm on May 15, 2009 (gmt 0)
I have two similarly structured arrays and i want to take all the values from the second array and put them into the first array in the appropriate place (AND overwrite the original value if it was set).
$array1 + $array2 doesn't seem to like multi-dimensional arrays. array_merge didn't seem to be the answer either because there could be numeric keys involved. I thought about writing a recursive function to loop through all the values, but i couldn't figure out how to find the appropriate place in the other array to put the new value.
it seems like there is a fairly good lack of built in recursive functions for arrays.
Msg#: 3914527 posted 9:17 pm on May 18, 2009 (gmt 0)
Hm.. this is a bit more complicated that I anticipated lol... I am running php 4 so I haven't been able to play with all the new php array functions. If you are in the same boat, likely you'll have to write a function. array_merge($arr1, $arr2) returns $arr2. Perhaps if you have php 5 you can do array_merge() -> array_combine(). Sorry, I can't be of any help - looks like this is one tough egg to crack! Good luck.