English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The strrchr() function is used to find the last occurrence of a specified character in a string.
strrchr(string, char)
It is used to find the last occurrence of a character in a string.
Returns the remaining part of the string (from the matching position). If the searched string is not found, it returns FALSE.
Serial Number | Parameters and Description |
---|---|
1 | string It specifies the string to be searched |
2 | char It specifies the string to be searched. If the parameter is a number, it searches for the character corresponding to the ASCII value of that number. |
Try the following example, which returns the substring before the first occurrence of "PHP":
<?php //Returns the substring before the first occurrence of "PHP" echo strrchr("Hello PHP, very good!", "PHP"); ?>Test and see‹/›
Output Result
P, very good!