X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP strrchr() Function

PHP String Reference PHP String Reference

Example

Search a string for "world", and return all characters from this position to the end of the string:

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

Run example »

Definition and Usage

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.


Syntax

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

Technical Details

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


More Examples

Example 1

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);
?>

Run example »

Example 2

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);
?>

Run example »


PHP String Reference PHP String Reference


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook