note 74762 deleted from ref.array by felipe

From: Date: Sun, 30 Dec 2007 19:29:12 +0000
Subject: note 74762 deleted from ref.array by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134529@lists.php.net to get a copy of this message
Note Submitter: frando ---- This is a super-hard array conversion function. It only returns TRUE if the two arrays are completely identical, that means that they have the same keys, and the values of all keys are exactly the same (compared with ===). <?php function array_same($a1, $a2) { if (!is_array($a1) || !is_array($a2)) return false; $keys = array_merge(array_keys($a1), array_keys($a2)); foreach ($keys as $k) { if (!isset($a2[$k]) || !isset($a1[$k])) return false; if (is_array($a1[$k]) || is_array($a2[$k])) { if (!array_same($a1[$k], $a2[$k])) return false; } else { if (! ($a1[$k] === $a2[$k])) return false; } } return true; } ?>

« previous php.notes (#134529) next »