Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP strrchr() Function

PHP strrchr() Function

PHP String Reference Manual PHP String Reference Manual

Example

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

Run Example »


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

strrchr(

string,char

)

Parameters Description
string Required. Specifies the string to be searched.
char Required. Specifies the character to find. If this parameter is a number, it searches for the character matching the ASCII value of that 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, FALSE is returned.
PHP Version: 4+
Changelog: In PHP 4.3, this function became binary-safe.

More examples

Example 1

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

Run Example »

Example 2

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

Run Example »


PHP String Reference Manual PHP String Reference Manual