note 107821 added to function.in-array
| From: | dlancea | Date: | Wed, 07 Mar 2012 16:25:01 +0000 |
| Subject: | note 107821 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186529@lists.php.net to get a copy of this message | ||
FYI, the in_arrayr function below is incorrect. It will not continue past the first rested array
(and return false if not found). Corrected version is below:
<?php
function in_arrayr( $needle, $haystack ) {
foreach( $haystack as $v ){
if( $needle == $v )
return true;
elseif( is_array( $v ) )
if( in_arrayr( $needle, $v ) )
return true;
}
return false;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 134.192.250.68
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/107821
Del: integrated -- https://master.php.net/note/delete/107821/integrated
Del: useless -- https://master.php.net/note/delete/107821/useless
Del: bad code -- https://master.php.net/note/delete/107821/bad+code
Del: spam -- https://master.php.net/note/delete/107821/spam
Del: non-english -- https://master.php.net/note/delete/107821/non-english
Del: in docs -- https://master.php.net/note/delete/107821/in+docs
Del: other reasons-- https://master.php.net/note/delete/107821
Reject -- https://master.php.net/note/reject/107821
Search -- https://master.php.net/manage/user-notes.php