Home > Backend Development > PHP Tutorial > How to use php strrchr function

How to use php strrchr function

藏色散人
Release: 2023-04-05 06:22:01
Original
6066 people have browsed it

PHP strrchr function is used to find the last occurrence of a specified character in a string. Its syntax is strrchr (string, char). The parameter string is required and specifies the string to be searched; char is required and specifies the string to be searched. character.

How to use php strrchr function

php How to use strrchr function?

php strrchr() function syntax

Function: Returns the position of the last occurrence of a string in another string, and returns all characters from that position to the end of the string Characters

Syntax:

strrchr(string,char)
Copy after login

Parameters:

string Required. Specifies the string to search for.​

char Required. Specifies the characters to search for. If the argument is a number, searches for characters matching the ASCII value of this number.

Description:

Find the last occurrence of a string in another string and return all characters from that position to the end of the string.

This function is binary safe.

php strrchr() function usage example 1:

<?php
echo strrchr("I&#39;m study in php.cn!","study");
?>
Copy after login

Output:

study in php.cn!
Copy after login

php strrchr() function usage example 2:

<?php
echo strrchr("i like php","like");
?>
Copy after login

Output:

like php
Copy after login

This article is an introduction to the PHP strrchr function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use php strrchr function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template