note 103249 added to function.strpos
| From: | sean at roi dot com dot au | Date: | Mon, 04 Apr 2011 01:32:25 +0000 |
| Subject: | note 103249 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178454@lists.php.net to get a copy of this message | ||
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);
}
}
----
Server IP: 117.55.229.1
Probable Submitter: 210.15.233.53
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- https://master.php.net/note/edit/103249
Del: integrated -- https://master.php.net/note/delete/103249/integrated
Del: useless -- https://master.php.net/note/delete/103249/useless
Del: bad code -- https://master.php.net/note/delete/103249/bad+code
Del: spam -- https://master.php.net/note/delete/103249/spam
Del: non-english -- https://master.php.net/note/delete/103249/non-english
Del: in docs -- https://master.php.net/note/delete/103249/in+docs
Del: other reasons-- https://master.php.net/note/delete/103249
Reject -- https://master.php.net/note/reject/103249
Search -- https://master.php.net/manage/user-notes.php