PHP strrpos() Function
Example
Find the last occurrence of "php" in a string:
Run Example »
Definition and Usage
The strrpos() function finds the last occurrence of a string within another string (case-sensitive).
**Note:** The strrpos() function is case-sensitive.
Related functions:
- strpos() - Find the first occurrence of a string within another string (case-sensitive)
- stripos()- Find the first occurrence of a string within another string (case-insensitive)
- strripos() - Find the last occurrence of a string within another string (case-insensitive)
Syntax
strrpos(
string,find,start
)
| Parameters | Description |
|---|---|
| string | Required. Specifies the string to be searched. |
| find | Required. Specifies the characters to find. |
| start | Optional. Specifies the position to start searching. |
Technical Details
| Return Value: | Returns the position of the last occurrence of a string within another string, or FALSE if the string is not found.Note: String positions start at 0, not 1. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | Since PHP 5.0, thefind parameter can be a string of more than one character. |
在 PHP 5.0 中,新增了 *start* 参数。 |
PHP String Reference Manual