Skip to content

Instantly share code, notes, and snippets.

@cha55son
Created September 4, 2013 19:09
Show Gist options
  • Save cha55son/6441411 to your computer and use it in GitHub Desktop.
Save cha55son/6441411 to your computer and use it in GitHub Desktop.
Simple PHP function to emulate the jQuery extend feature.
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