Home  >  Article  >  Backend Development  >  How to use php strrpos function?

How to use php strrpos function?

青灯夜游
青灯夜游Original
2019-05-30 13:14:362912browse

php The strrpos() function is used to find the last occurrence of a string in another string (case sensitive). The syntax is strrpos(string,find,start). If the string is not found, FALSE is returned.

How to use php strrpos function?

php How to use strrpos() function?

strrpos() function finds the last occurrence of a string in another string, that is, it searches for 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.

Return value: Returns the position of the last occurrence of a string in another string, or FALSE if the string is not found.

Note: strrpos() function is case-sensitive, and the string position starts from 0, not from 1.

Let’s take a look at how to use the php strrpos() function through an example.

Example 1:

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

Output:

21

Example 2:

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

Output:

bool(false)

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