Created
September 4, 2013 19:09
-
-
Save cha55son/6441411 to your computer and use it in GitHub Desktop.
Simple PHP function to emulate the jQuery extend feature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_extend() { | |
$arrays = func_get_args(); | |
$base = array_shift($arrays); | |
foreach ($arrays as $array) { | |
reset($base); | |
while (list($key, $value) = @each($array)) | |
if (is_array($value) && @is_array($base[$key])) | |
$base[$key] = array_extend($base[$key], $value); | |
else $base[$key] = $value; | |
} | |
return $base; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment