"Prachait Saxena" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > 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, " <"); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php