Skip to content

Commit

Permalink
Merge pull request #174 from rawbertp/rp-fix-array-deep-merge
Browse files Browse the repository at this point in the history
Fix errors in arrayDeepMerge for non-existing keys
  • Loading branch information
sualko authored Nov 1, 2019
2 parents 22a9e96 + 28b6d27 commit 9222eb8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/arrayDeepMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function array_deep_merge()
$args[2] = array();
if (is_array($args[0]) and is_array($args[1])) {
foreach (array_unique(array_merge(array_keys($args[0]), array_keys($args[1]))) as $key) {
if (is_string($key) and is_array($args[0][$key]) and is_array($args[1][$key])) {
if (is_string($key) and array_key_exists($key, $args[0]) and is_array($args[0][$key]) and array_key_exists($key, $args[1]) and is_array($args[1][$key])) {
$args[2][$key] = array_deep_merge($args[0][$key], $args[1][$key]);
} elseif (is_string($key) and isset($args[0][$key]) and isset($args[1][$key])) {
$args[2][$key] = $args[1][$key];
Expand Down

0 comments on commit 9222eb8

Please sign in to comment.