PHP strrchr() Function
Example
Search a string for "world", and return all characters from this position to the end of the string:
<?php
echo strrchr("Hello world!","world");
?>
Try it Yourself »
Definition and Usage
The strrchr() function finds the position of the last occurrence of a string within another string, and returns all characters from this position to the end of the string.
Note: This function is binary-safe.
Syntax
strrchr(string,char)
Parameter Values
Parameter | Description |
---|---|
string | Required. Specifies the string to search |
char | Required. Specifies the string to find. If this is a number, it will search 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, or FALSE if the character is not found |
---|---|
PHP Version: | 4+ |
Changelog: | This function was made binary-safe in PHP 4.3 |
More Examples
Example
Search a string for "What", and return all characters from this position to the end of the string:
<?php
echo strrchr("Hello world! What a beautiful day!", "What");
?>
Try it Yourself »
Example
Search a string for the ASCII value of "e" (101) and return all characters from this position to the end of the string:
<?php
echo strrchr("Hello world!",101);
?>
Try it Yourself »
❮ PHP String Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.