function md_array_merge(){ $arrays = func_get_args(); $return = array(); foreach($arrays as $array){ foreach($array as $key=>$val){ if(is_array($val) && isset($return[$key])){ $return[$key] = md_array_merge($return[$key], $val); } else { $return[$key] = $val; } } } return $return; }
I wrote the above function to merge 2 or more multidimensional arrays. Use is similar to array_merge().
Provided with Open Source license without warranty
Great snippet! Saved me a lot of time. Thanks for sharing.
ReplyDelete