MENU
Searching
To find the position of $s2 in $s1, use:strpos($s1,$s2[,$i=0]);
stripos($s1,$s2[,$i=0]);
strrpos($s1,$s2[,$i=0]);
strripos($s1,$s2[,$i=0]);
FALSE is returned if $s2 cannot be found. ‘i’ performs a case-insensitive search. ‘r’ searches for the last instead of the first occurrence. $i denotes the starting position of the search. For strrpos(……) and strripos(……), if $i is negative, the search will start -$i characters from the end, searching backwards.
Notice the use of ===. FALSE and 0 are equivalent in values but not in types.
RESETRUNFULL
RESETRUNFULL
<!DOCTYPE html><html><head></head>
<body><?php
echo strpos("abcabc","abc",1);
echo stripos("abcabc","ABC",1);
echo strrpos("abcabc","abc",-4);
echo strripos("abcabc","ABC",-4);
echo "<br/>";
if (strpos("aaa","bb")===FALSE) echo "string not found";
?></body></html>