The mb_stripos Function
The mb_stripos function finds the first occurrence of a substring in a string, ignoring character case.
Unlike stripos, it works correctly with multibyte encodings (UTF-8 and others). Its first parameter is the string to search in, the second is the substring to find, the third (optional) is the starting position for the search, and the fourth is the encoding.
Syntax
mb_stripos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false
Example
Find the position of a substring in a string:
<?php
$res = mb_stripos('AbCdE', 'bc');
echo $res;
?>
Code execution result:
1
Example
Search with a specified starting position:
<?php
$res = mb_stripos('AbCdE', 'cd', 2);
echo $res;
?>
Code execution result:
2
Example
Search with encoding specified:
<?php
$res = mb_stripos('Привет мир', 'МИР', 0, 'UTF-8');
echo $res;
?>
Code execution result:
7