note 74762 added to ref.array

From: Date: Thu, 26 Apr 2007 14:14:59 +0000
Subject: note 74762 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-125891@lists.php.net to get a copy of this message
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; } ?> ---- Server IP: 212.124.37.9 Probable Submitter: 88.64.154.33 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/74762 Del: integrated -- https://master.php.net/note/delete/74762/integrated Del: useless -- https://master.php.net/note/delete/74762/useless Del: bad code -- https://master.php.net/note/delete/74762/bad+code Del: spam -- https://master.php.net/note/delete/74762/spam Del: non-english -- https://master.php.net/note/delete/74762/non-english Del: in docs -- https://master.php.net/note/delete/74762/in+docs Del: other reasons-- https://master.php.net/note/delete/74762 Reject -- https://master.php.net/note/reject/74762 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125891) next »