<?php
public function merge(array $a, array $b, $preserveNumericKeys = false)
{
foreach ($b as $key => $value) {
if (array_key_exists($key, $a)) {
if (is_int($key) && !$preserveNumericKeys) {
$a[] = $value;
} elseif (is_array($value) && is_array($a[$key])) {
$a[$key] = static::merge($a[$key], $value, $preserveNumericKeys);
} else {
$a[$key] = $value;
}
} else {
$a[$key] = $value;
}
}
return $a;
}
merge(array('franz', 'de leon'), array('franz', 'kafka'));
- Output for 5.4.0 - 5.4.28
- Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/7mjBX on line 2
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected T_PUBLIC in /in/7mjBX on line 2
Process exited with code 255.
preferences:
195.76 ms | 1395 KiB | 65 Q