Skip to content

Instantly share code, notes, and snippets.

@ollym
Created January 25, 2010 15:55
Show Gist options
  • Save ollym/285957 to your computer and use it in GitHub Desktop.
Save ollym/285957 to your computer and use it in GitHub Desktop.
public static function merge(array $array1, array $_)
{
$result = array();
foreach (func_get_args() as $array)
{
$i = 0;
foreach ($array as $key => $value)
{
if (isset($result[$key]))
{
if ($key === $i)
{
array_push($result, $value);
}
elseif (is_array($value))
{
$result[$key] = self::merge($result[$key], $value);
}
else
{
$result[$key] = $value;
}
}
else
{
$result[$key] = $value;
}
$i++;
}
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment