note 36290 added to function.strpos
| From: | peous at rn2 dot php dot net | Date: | Fri, 03 Oct 2003 17:54:16 +0000 |
| Subject: | note 36290 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57773@lists.php.net to get a copy of this message | ||
Function to find the first occurence of any object of the array.
function findfirstof( $txt, $arr, $start )
{
$pos = -1;
foreach( $arr as $v )
{
$p = strpos( $txt, $v, $start );
if ($p===FALSE)
continue;
if (($p<$pos)||($pos==-1))
$pos = $p;
}
return $pos;
}
Ex:
$str = "find, the first word...";
$firstW = findfirstof( $str, ",?.:!" );//returns "find"
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36290
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36290&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36290&report=yes