note 82890 added to function.array-key-exists

From: Date: Wed, 30 Apr 2008 16:22:20 +0000
Subject: note 82890 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-138940@lists.php.net to get a copy of this message
I noticed that the function for recursion broke the ability to use this on objects, so I added another check to also allow it to work for objects. <?php function array_key_exists_r($needle, $haystack) { $result = array_key_exists($needle, $haystack); if ($result) return $result; foreach ($haystack as $v) { if (is_array($v) || is_object($v)) $result = array_key_exists_r($needle, $v); if ($result) return $result; } return $result; } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 64.113.224.62 ---- Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php Edit -- https://master.php.net/note/edit/82890 Del: integrated -- https://master.php.net/note/delete/82890/integrated Del: useless -- https://master.php.net/note/delete/82890/useless Del: bad code -- https://master.php.net/note/delete/82890/bad+code Del: spam -- https://master.php.net/note/delete/82890/spam Del: non-english -- https://master.php.net/note/delete/82890/non-english Del: in docs -- https://master.php.net/note/delete/82890/in+docs Del: other reasons-- https://master.php.net/note/delete/82890 Reject -- https://master.php.net/note/reject/82890 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138940) next »