Easy Tutorial
❮ Func Filesystem Is File Func Array Sort ❯

PHP strrchr() Function

PHP String Reference Manual

Example

Search for "world" in the string and return all characters from that position to the end of the string:


Definition and Usage

The strrchr() function finds the last occurrence of a string within another string and returns all characters from that position to the end of the string.

Note: This function is binary-safe.


Syntax

Parameter Description
string Required. Specifies the string to be searched.
char Required. Specifies the character to search for. If this parameter is a number, it searches for the character matching the ASCII value of the number.

Technical Details

Return Value: Returns all characters from the last occurrence of a string within another string to the end of the main string. If the character is not found, it returns FALSE.
PHP Version: 4+
--- ---
Changelog: This function became binary-safe in PHP 4.3.
--- ---

More Examples

Example 1

Search for "" in the string and return all characters from that position to the end of the string:

Example 2

Search for "o" in the string using the ASCII value of "o" and return all characters from that position to the end of the string:


PHP String Reference Manual

❮ Func Filesystem Is File Func Array Sort ❯