Php Programming Code Examples
Php > Complete Programs Code Examples
Look for the position of the first occurence of string2
Look for the position of the first occurence of string2
<?
/*
Look for the *position* of the first occurence of string2
in string1, beginning at position start.
*/
function InStr($Start, $String1, $String2)
{
$i = $Start;
while ($i < strlen($String1) - strlen($String2))
{
if (substr($String1, $i, strlen($String2)) == $String2)
{
return $i;
exit();
}
$i++;
}
return 0;
}
?>