Home  >  Article  >  Backend Development  >  How to use php strrchr function

How to use php strrchr function

藏色散人
藏色散人Original
2019-02-01 10:45:466026browse

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)

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");
?>

Output:

study in php.cn!

php strrchr() function usage example 2:

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

Output:

like php

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!

Statement:
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