strrchr
Find the last occurrence of a specified character in a string
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.
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
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
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
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. |