Home » PHP strrchr() Function

PHP strrchr() Function

by Online Tutorials Library

PHP strrchr() Function

The strrchr() function in inbuilt function of PHP. It is used to find the position of the last occurrence of a string.

This function returns all characters from this position to the end of the string or FALSE if the character is not found.

Note: The strrchr() function is binary-safe.

Syntax:

Parameter Description Required/Optional
String Specify the string to search. required
Char Specify the string to find by using ASCII value. required

Example 1

Output:

Your first string is:Hello PHP  Your second string is:PHP  By using 'strrchr()' function:P  

Example 2

Output:

Your string is:We are Learning PHP  By using 'strrchr()' function:arning PH  

Example 3

Output:

Your string is:Hello PHP  By using 'strrchr()' function:ello PHP  

See Also:

strncmp() : String comparison of the first n characters (case-sensitive)

strpbrk() : Searches a string for any of a set of characters

strpos() :Returns the position of the first occurrence of a string inside another string (case-sensitive)

Refererence:

http://php.net/manual/en/function.strrchr.php

Next TopicPHP String

You may also like