note 117845 added to function.array-key-exists

From: Date: Wed, 19 Aug 2015 10:36:46 +0000
Subject: note 117845 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-203384@lists.php.net to get a copy of this message
If u want to check if a key exists either in the array or in any subarray try the following: <?php function requireKey($needle, array $array) { foreach ($array as $key => $value) { if ($key === $needle) return $value; if (is_array($value)) { if ($x = $this->requireKey($key, $value)) return $x; } } return false; } ?> (( return $value for recursive array search, return true for recursive array key exists )) ---- Server IP: 72.52.91.14 Probable Submitter: 213.30.253.142 ---- Manual Page -- http://php.net/manual/en/function.array-key-exists.php Edit -- https://master.php.net/note/edit/117845 Del: integrated -- https://master.php.net/note/delete/117845/integrated Del: useless -- https://master.php.net/note/delete/117845/useless Del: bad code -- https://master.php.net/note/delete/117845/bad+code Del: spam -- https://master.php.net/note/delete/117845/spam Del: non-english -- https://master.php.net/note/delete/117845/non-english Del: in docs -- https://master.php.net/note/delete/117845/in+docs Del: other reasons-- https://master.php.net/note/delete/117845 Reject -- https://master.php.net/note/reject/117845 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203384) next »