note 25640 deleted from function.in-array by felipe

From: Date: Sun, 30 Dec 2007 18:50:21 +0000
Subject: note 25640 deleted from function.in-array by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134467@lists.php.net to get a copy of this message
Note Submitter: bbisgod AT hotmail DOT com ---- I had a HUGE problem of comparing references to see if they were pointing to the same object. I ended up using this code! function in_o_array (&$needle, &$haystack) { if (!is_array($haystack)) return false; foreach ($haystack as $key => $val) { if (check_refs($needle, $haystack[$key])) return true; } return false; } function check_refs(&$a, &$b) { $tmp = uniqid(""); $a->$tmp = true; $bResult = !empty($b->$tmp); unset($a->$tmp); return $bResult; } Hope this helps someone have a more productive morning that me! :P

« previous php.notes (#134467) next »