Syntax of strrchr() function and Usage:
strrchr(string,char)
Parameter Values
string -> The string to search in.
char -> contains more than one character, only the first is used. This behavior is different from that of strstr().
If this is a number, it will search for the character matching the ASCII value of that number.
Let's learn
1.Create strrchr().
strrchr("Hello world! Welcome to BAJARANGISOFT", "Welcome")
2.Print string using strrchr() function.
echo strrchr("Hello world! Welcome to BAJARANGISOFT", "Welcome");
<?php
echo strrchr("Hello world! Welcome to BAJARANGISOFT", "Welcome");
?>
Complete Code of strrchr() Function:
<!DOCTYPE html>
<html lang="en">
<head>
<title>PHP strrchr function</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="text-center">
<h1>PHP strrchr() Function</h1>
</div>
<br>
<h2>The strrchr() function is used to find the last occurrence of a character in a string.</h2>
<div class="well">
<?php
echo "<h2>". strrchr("Hello world! Welcome to BAJARANGISOFT", "Welcome") ."</h2>";
?>
</div>
<br>
</div>
</body>
</html>