note 103249 deleted from function.strpos by danbrown
| From: | danbrown@php.net | Date: | Mon, 04 Apr 2011 14:22:18 +0000 |
| Subject: | note 103249 deleted from function.strpos by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-178465@lists.php.net to get a copy of this message | ||
Note Submitter: sean at roi dot com dot au
----
Just a note to anyone who uses akarmenia's function from below; it's very helpful but
there's a slight problem. Since it doesn't return FALSE by default if you try to use this
function the same way the core function is used (!== FALSE) it won't work properly.
Please see my minor fix below;
function strpos_array($haystack, $needles) {
if ( is_array($needles) ) {
foreach ($needles as $str) {
if ( is_array($str) ) {
$pos = strpos_array($haystack, $str);
} else {
$pos = strpos($haystack, $str);
}
if ($pos !== FALSE) {
return $pos;
}
}
return FALSE;
} else {
return strpos($haystack, $needles);
}
}