Re: finding postion of any chat occur first
| From: | Hugh Bothwell | Date: | Mon, 20 May 2002 02:12:06 +0000 |
| Subject: | Re: finding postion of any chat occur first | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98408@lists.php.net to get a copy of this message | ||
"Prachait Saxena" <prachait@nagpur.dot.net.in> wrote in message
news:20020519184950.72685.qmail@pb1.pair.com...
> I have a string like $str="Hello World > <<";
> and i want to find the first occurance of any one of the char in " " or
"<"
>
> $sp=strpos($str,">")
> Did not work, beacuse in this I can give only one char....
function strpos_multi($str, $chars) {
$firstpos = $badvalue = $strlen($str);
$numchars = strlen($chars);
for ($i = 0; $i < $numchars; $i++) {
$ch = substr($chars, $i, 1);
$pos = strpos($str, $ch);
if ($pos !== false) // NOTE: op is bang-equals-equals
$firstpos = min($pos, $firstpos);
}
if ($firstpos == $badvalue)
return -1;
else
return $firstpos;
}
$charpos = strpos_multi($str, " <");