Latest web development tutorials

PHP strrchr () function

PHP String Reference PHP String Reference

Examples

Search for "world" position in the string, and returns all the characters from that position to the end of the string:

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

Running instance »

Definition and Usage

strrchr () function to find the position of a string within another string of the last occurrence, and returns all the characters from that position to the end of the string.

Note: This function is binary safe.


grammar

strrchr( string,char )

参数 描述
string 必需。规定被搜索的字符串。
char 必需。规定要查找的字符。如果该参数是数字,则搜索匹配数字 ASCII 值的字符。

technical details

return value: Returns all the characters from the position of a string within another string of the last occurrence of the primary end of the string. If not found, it returns FALSE.
PHP version: 4+
Update log: In PHP 4.3, the function becomes binary safe.


More examples

Example 1

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

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

Running instance »

Example 2

Through the "o" in the ASCII value of the search for "o" position in the string, and returns all the characters from that position to the end of the string:

<?php
echo strrchr("Hello world!",111);
?>

Running instance »


PHP String Reference PHP String Reference