note 2569 deleted from function.in-array by jimw
| From: | jimw@php.net | Date: | Fri, 07 Dec 2001 21:06:07 +0000 |
| Subject: | note 2569 deleted from function.in-array by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-21959@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;
}