1stripos ( string $haystack , string $needle , int $offset = 0 ) : int|false
2
3<?php
4 $findme = 'a';
5 $mystring1 = 'xyz';
6 $mystring2 = 'ABC';
7
8 $pos1 = stripos($mystring1, $findme);
9 $pos2 = stripos($mystring2, $findme);
10
11 // Nope, 'a' is certainly not in 'xyz'
12 if ($pos1 === false) {
13 echo "The string '$findme' was not found in the string '$mystring1'";
14 }
15
16 // Note our use of ===. Simply == would not work as expected
17 // because the position of 'a' is the 0th (first) character.
18 if ($pos2 !== false) {
19 echo "We found '$findme' in '$mystring2' at position $pos2";
20 }
21?>