note 91812 deleted from function.array-diff by danbrown

From: Date: Thu, 10 Sep 2009 00:56:05 +0000
Subject: note 91812 deleted from function.array-diff by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160388@lists.php.net to get a copy of this message
Note Submitter: firegun at terra dot com dot br ---- Ops! The last function have a little mistake (it was inside a object, there´s a $this call..), here is the correct: <?php function arrayRecursiveDiff($aArray1, $aArray2) { $aReturn = array(); foreach ($aArray1 as $mKey => $mValue) { if (array_key_exists($mKey, $aArray2)) { if (is_array($mValue)) { $aRecursiveDiff = arrayRecursiveDiff($mValue, $aArray2[$mKey]); if (count($aRecursiveDiff)) { $aReturn[$mKey] = $aRecursiveDiff; } } else { if ($mValue != $aArray2[$mKey]) { $aReturn[$mKey] = $mValue; } } } else { $aReturn[$mKey] = $mValue; } } return $aReturn; } ?>

« previous php.notes (#160388) next »