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

How to use php strrpos function

藏色散人
藏色散人Original
2019-02-11 10:12:403080browse

php The strrpos function is used to calculate the position of the last occurrence of the specified string in the target string. Its syntax is strrpos(string, find, start). The parameter string is required, which refers to the specified string to be searched; find is required, Refers to the specified character to be searched for.

How to use php strrpos function

#php How to use strrpos function?

php strrpos() function syntax

Function: Find the last occurrence of a character in a string

Syntax:

strrpos(string,find,start)

Parameters:

string Required. Specifies the string to be searched for.

find Required. Specifies the characters to search for.

start Optional. Specifies where to start the search.

Description:

Find the last occurrence of a string in another string. The strrpos() function is case-sensitive.

php strrpos() function usage example 1

<?php
echo strrpos("You love php, I love php too!","php");
?>

Output:

21

php strrpos() function usage example 2

<?php
var_dump(strrpos("You love php, I love php too!","PHP")) ;
?>

Output:

bool(false)

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

The above is the detailed content of How to use php strrpos 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