Current Location: Home> Function Categories> strrchr

strrchr

Find the last occurrence of a specified character in a string
Name:strrchr
Category:String
Programming Language:php
One-line Description:Find the last time a string appears in another string.

Definition and usage

strrchr() function finds the last location of the string in another string and returns all characters from that location to the end of the string.

Note: This function is binary safe.

Example

Example 1

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

 <?php
echo strchr ( "I love Shanghai!" , "Shanghai" ) ;
?>

Try it yourself

Example 2

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

 <?php
echo strchr ( "Hello world! What a beautiful day!" , What ) ;
?>

Try it yourself

Example 3

Searches for the position of "o" in the string with the ASCII value of "o" and returns all characters from that position to the end of the string:

 <?php
echo strchr ( "Hello world!" , 101 ) ;
?>

Try it yourself

grammar

 strrchr ( string , char )
parameter describe
string Required. Specifies the string to search.
char Required. Specifies the characters to be searched. If the parameter is a number, search for characters matching the ASCII value of this number.
Similar Functions
Popular Articles