mb_strripos
Case insensitively find the last location of a string in a string
Function name: mb_strripos()
Applicable version: PHP 4 >= 4.2.0, PHP 5, PHP 7
Function Description: The mb_strripos() function returns the last occurrence of the specified string in another string (case insensitive). If the string is not found, false is returned.
Syntax: mb_strripos(string $haystack, string $needle, int $offset = 0, string $encoding = null): int|bool
parameter:
Return value:
Example 1:
$string = "Hello, World!"; $needle = "world"; $position = mb_strripos($string, $needle); if ($position !== false) { echo "找到了needle 在haystack 中的位置:$position"; } else { echo "未找到needle 在haystack 中"; }
Output:
找到了needle 在haystack 中的位置:7
Example 2:
$string = "Hello, World!"; $needle = "WORLD"; $position = mb_strripos($string, $needle); if ($position !== false) { echo "找到了needle 在haystack 中的位置:$position"; } else { echo "未找到needle 在haystack 中"; }
Output:
找到了needle 在haystack 中的位置:7
Notes: