The stripos Function
The stripos
function finds the first occurrence of a substring in a string, ignoring case. Its first parameter is the string to search in, the second is the substring to search for, and the third optional parameter is the position to start the search from.
Syntax
stripos(string, substring, [offset]);
Example
Find the position of a substring in a string:
<?php
echo stripos('AbCdE', 'bc');
?>
Code execution result:
1
Example
Try to find a non-existent substring:
<?php
$res = stripos('AbCdE', 'xyz');
var_dump($res);
?>
Code execution result:
false
Example
Search with a specified starting position:
<?php
echo stripos('aAbBcC', 'b', 3);
?>
Code execution result:
4