mb_strripos
大小写不敏感地在字符串中查找一个字符串最后出现的位置
函数名:mb_strripos()
适用版本:PHP 4 >= 4.2.0, PHP 5, PHP 7
函数说明:mb_strripos() 函数返回指定字符串在另一个字符串中最后一次出现的位置(不区分大小写)。如果未找到该字符串,则返回 false。
语法:mb_strripos(string $haystack, string $needle, int $offset = 0, string $encoding = null): int|bool
参数:
返回值:
示例 1:
$string = "Hello, World!";
$needle = "world";
$position = mb_strripos($string, $needle);
if ($position !== false) {
echo "找到了 needle 在 haystack 中的位置:$position";
} else {
echo "未找到 needle 在 haystack 中";
}
输出:
找到了 needle 在 haystack 中的位置:7
示例 2:
$string = "Hello, World!";
$needle = "WORLD";
$position = mb_strripos($string, $needle);
if ($position !== false) {
echo "找到了 needle 在 haystack 中的位置:$position";
} else {
echo "未找到 needle 在 haystack 中";
}
输出:
找到了 needle 在 haystack 中的位置:7
注意事项: