note 107821 deleted from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 18:24:31 +0000 |
| Subject: | note 107821 deleted from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187752@lists.php.net to get a copy of this message | ||
Note Submitter: dlancea
----
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;
}
?>