The mb_strripos Function
The mb_strripos function finds the position of the last occurrence of a substring in a string, ignoring character case. The first parameter is the string to search in, the second is the substring to search for. The third optional parameter specifies the position to start the search from. The fourth optional parameter specifies the encoding.
Syntax
phpmb_strripos(
string $haystack,
string $needle,
int $offset = 0,
string $encoding = null
): int|false
Example
Find the last occurrence of a substring in a string:
php<?php
$res = mb_strripos('aBcDeBc', 'bc');
echo $res;
?>
Execution result:
php5
Example
Search with a specified starting position:
php<?php
$res = mb_strripos('aBcDeBc', 'bc', 3);
echo $res;
?>
Execution result:
php5
Example
If the substring is not found, the function will return false:
php<?php
$res = mb_strripos('abcde', 'z');
var_dump($res);
?>
Execution result:
phpfalse