Add the keys/values in `$array2` that are not found in `$array` onto the end of `$array`.
Parameters
- mixed $array Original array.
- mixed $array2 Second array to add onto the original.
Returns
array An array containing all the keys of the second array not already present in the first.Source
public static function append(array $array, array $array2) {
if (!$array && $array2) {
return $array2;
}
foreach ($array2 as $key => $value) {
if (!isset($array[$key])) {
$array[$key] = $value;
} elseif (is_array($value)) {
$array[$key] = static::append($array[$key], $array2[$key]);
}
}
return $array;
}