Voting

: six minus five?
(Example: nine)

The Note You're Voting On

martyniuk dot vasyl at gmail dot com
13 years ago
This is my version of array_merge_recursive without overwriting numeric keys:
<?php
function array_merge_recursive_new() {

$arrays = func_get_args();
$base = array_shift($arrays);

foreach (
$arrays as $array) {
reset($base); //important
while (list($key, $value) = @each($array)) {
if (
is_array($value) && @is_array($base[$key])) {
$base[$key] = array_merge_recursive_new($base[$key], $value);
} else {
$base[$key] = $value;
}
}
}

return
$base;
}
?>

<< Back to user notes page

To Top