PHP strripos() 函数
定义和用法
strripos() 函数查找字符串在另一字符串中最后一次出现的位置(不区分大小写)。
注释:strripos() 函数是不区分大小写的。
相关函数:
- stripos() - 查找字符串在另一字符串中第一次出现的位置(不区分大小写)
- strpos() - 查找字符串在另一字符串中第一次出现的位置(区分大小写)
- strrpos() - 查找字符串在另一字符串中最后一次出现的位置(区分大小写)
语法
strripos(string,find,start)
参数 | 描述 |
---|---|
string | 必需。规定被搜索的字符串。 |
find | 必需。规定要查找的字符。 |
start | 可选。规定开始搜索的位置。 |
技术细节
返回值: | 返回字符串在另一字符串中最后一次出现的位置,如果没有找到字符串则返回 FALSE。注释: 字符串位置从 0 开始,不是从 1 开始。 |
---|---|
PHP 版本: | 5+ |
更新日志: | 自 PHP 5.0 起,find 参数可以是一个超过一个字符的字符串。 在 PHP 5.0 中,新增了 start 参数。 |

文人墨客
strpos, strrpos, stripos, strripos 词义解析:
大王叫我来巡山1998
strripos — Find the position of the last occurrence of a case-insensitive substring in a string (PHP 5, PHP 7)
strripos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int
Find the numeric position of the last occurrence of needle in the haystack string.
strripos() is case-insensitive.
Parameters
haystack
The string to search in.
needle
If needle is not a string, it is converted to an integer and applied as the ordinal value of a character. This behavior is deprecated as of PHP 7.3.0, and relying on it is highly discouraged. Depending on the intended behavior, the needle should either be explicitly cast to string, or an explicit call to chr() should be performed
offset
If zero or positive, the search is performed left to right skipping the first offset bytes of the haystack
If negative, the search is performed right to left skipping the last offset bytes of the haystack and searching for the first occurrence of needle
This is effectively looking for the last occurrence of needle before the last offset bytes
Return Values
Returns the position where the needle exists relative to the beginnning of the haystack string (independent of search direction or offset).
String positions start at 0, and not 1.
Returns FALSE if the needle was not found.
Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE.
Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.