note 90065 added to function.strpos
| From: | vbraccoatgmaildotcom at osu1 dot php dot net | Date: | Sat, 04 Apr 2009 14:45:03 +0000 |
| Subject: | note 90065 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152807@lists.php.net to get a copy of this message | ||
This function find position of first occurrence of any $needles in a string $haystack.
Return the position as an integer. If needles is not found, strposa() will return boolean FALSE.
function strposa($haystack ,$needles=array(),$offset=0){
$chr = array();
foreach($needles as $needle){
$chr[] = strpos($haystack,$needle,$offset);
}
if(empty($chr)) return false;
return min($chr);
}
$string = "This is my string, very simple.";
echo strposa($string,array(".",","," ")); // 2
echo strposa($string,array("T")); // 0
echo strposa($string,array("Q","W")); // false
----
Server IP: 201.216.232.3
Probable Submitter: 190.183.26.69
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- https://master.php.net/note/edit/90065
Del: integrated -- https://master.php.net/note/delete/90065/integrated
Del: useless -- https://master.php.net/note/delete/90065/useless
Del: bad code -- https://master.php.net/note/delete/90065/bad+code
Del: spam -- https://master.php.net/note/delete/90065/spam
Del: non-english -- https://master.php.net/note/delete/90065/non-english
Del: in docs -- https://master.php.net/note/delete/90065/in+docs
Del: other reasons-- https://master.php.net/note/delete/90065
Reject -- https://master.php.net/note/reject/90065
Search -- https://master.php.net/manage/user-notes.php