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:

ParameterDescriptionRequired/Optional
StringSpecify the string to search.required
CharSpecify 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




Latest Courses