Home >Backend Development >PHP Tutorial >How to use php strrpos function
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.
#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!