Home > Backend Development > PHP Tutorial > Detailed explanation of string function strrpos()

Detailed explanation of string function strrpos()

怪我咯
Release: 2023-03-08 06:48:01
Original
5341 people have browsed it

What is the role of string function strrpos()?

strrpos() function finds the last occurrence of a string within another string. This function is case-sensitive, contrary to the strripos() function, which is not case-sensitive. This article will guide you to understand the php strrpos() function.

strrpos() function syntax

strrpos(string,find,start)
Copy after login

This function has three parameters, the first two parameters are required, and the third parameter is optional Optional

ParameterDescription
stringRequired. Specifies the string to be searched for.
findRequired. Specifies the characters to search for.
startOptional. Specifies the location from which to start the search.

The return value of strrpos() function

strrpos() functionreturns a string The last occurrence of another string, or FALSE if the string is not found. The string position starts from 0, not from 1.

The related functions are:

  • stripos() - Find the first occurrence of a string in another string position (case-insensitive)

  • strpos() - Find the position of the first occurrence of a string in another string (case-sensitive)

  • strripos() - Find the last occurrence of a string in another string (case-insensitive)

strrpos() function example

The following example uses the strrpos() function to find the last occurrence of "php" in the string. The code is as follows

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

The code runs the browser output result:

Detailed explanation of string function strrpos()

[Related article recommendations]

php string function stripos Definition and usage of ()

php strpos() function example detailed explanation

php string function strripos() detailed example


The above is the detailed content of Detailed explanation of string function strrpos(). For more information, please follow other related articles on the PHP Chinese website!

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