Skip to content

Instantly share code, notes, and snippets.

@kuma-guy
Forked from vincenzodibiaggio/gist:5965342
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save kuma-guy/7f4faa6335491cf93556 to your computer and use it in GitHub Desktop.

Select an option

Save kuma-guy/7f4faa6335491cf93556 to your computer and use it in GitHub Desktop.
private function arrayRecursiveDiff($aArray1, $aArray2) {
$aReturn = array();
foreach ($aArray1 as $mKey => $mValue) {
if (array_key_exists($mKey, $aArray2)) {
if (is_array($mValue)) {
$aRecursiveDiff = $this->arrayRecursiveDiff($mValue, $aArray2[$mKey]);
if (count($aRecursiveDiff)) { $aReturn[$mKey] = $aRecursiveDiff; }
} else {
if ($mValue != $aArray2[$mKey]) {
$aReturn[$mKey] = $mValue;
}
}
} else {
$aReturn[$mKey] = $mValue;
}
}
return $aReturn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment