Php strrchr
From w3cyberlearnings
Contents |
PHP function strrchr
This function finds the last occurrence of string with another string.
Syntax strrchr
- string1: string input.
- string2: string to find (You can also use ASCII value).
strrchr(string1,string2)
Return
- Not Found: Return False
- Found: Return all the string from the position where found to the end.
Example 1
<?php echo strrchr("Excellent good and best!", "and"); ?>
Output
and best!
Example 2
<?php echo strrchr("The Excellent, The Good, and The Best!", "The"); ?>
Output
The Best!
Example 3: Use ASCII value
- echo ord('T') = 84 for the ASCII value.
<?php echo strrchr("The Excellent, The Good, and The Best!", 84); ?>
Output
The Best!