strrchr() function in PHP


The strrchr() function is used to find the last occurrence of a character in a string.

Syntax

strrchr(str, char)

Parameters

  • str − The string to search

  • char − The character to find in the string. If char contains more than one character, then only the first is used.

Return

The strrchr() function returns all characters from the last occurrence of a string within another string, to the end of the main string. It returns FALSE if the character is not found.

Example

The following is an example −

Live Demo

<?php
   echo strrchr("Welcome to the web","web");
?>

Output

web

Updated on: 30-Jul-2019

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements