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 »
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.
strrchr(
string,char)
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 |
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 |
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 »
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 »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!