note 109211 added to function.in-array

From: Date: Wed, 27 Jun 2012 08:51:06 +0000
Subject: note 109211 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-188904@lists.php.net to get a copy of this message
@kitchin The provided function in_arrayr does not work since it brakes out with return false after the first recursive search I have added a few lines of code and this one works function inArrayr($needle, $haystack) { foreach ($haystack as $value) { if ($needle == $value) { return true; } elseif (is_array($value)) { if(inArrayr($needle, $value)) return true; } } return false; } ---- Server IP: 69.147.83.197 Probable Submitter: 84.255.243.127 ---- Manual Page -- http://www.php.net/manual/en/function.in-array.php Edit -- https://master.php.net/note/edit/109211 Del: integrated -- https://master.php.net/note/delete/109211/integrated Del: useless -- https://master.php.net/note/delete/109211/useless Del: bad code -- https://master.php.net/note/delete/109211/bad+code Del: spam -- https://master.php.net/note/delete/109211/spam Del: non-english -- https://master.php.net/note/delete/109211/non-english Del: in docs -- https://master.php.net/note/delete/109211/in+docs Del: other reasons-- https://master.php.net/note/delete/109211 Reject -- https://master.php.net/note/reject/109211 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188904) next »