note 2569 modified in in_array by ronabop
| From: | ronabop@php.net | Date: | Wed, 18 Oct 2000 05:11:44 +0000 |
| Subject: | note 2569 modified in in_array by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6634@lists.php.net to get a copy of this message | ||
If you haven't gotten around to installing PHP4 yet, you could do:
(Not very optimized :) It could easily return the location of $needle instead
of just wheter or not it found it (uncomment).
function in_array($needle,$haystack) {
$found = false;
// $found = -1;
for($ptr=0;$ptr<count($haystack);$ptr++) {
if($haystack[$ptr] == $needle) {
$found = true;
// $found = $ptr;
}
}
return $found;
}
http://www.php.net/manual/function.in-array.php