SoFunction
Updated on 2025-03-10

php strrpos and strripos functions

strripos() function

Definition and usage
The strripos() function finds where the string last appears in another string.
Returns the position if successful, otherwise returns false.

grammar
strrpos(string,find,start)

parameter describe
string Required. Specifies the string being searched.
find Required. Specifies the characters to be searched.
start Optional. Specify the location to start the search.

Tips and comments
Note: This function is case-insensitive.

example:
 

Copy the codeThe code is as follows:

 <?php
echo strripos("Hello world!","WO");
?>
 

Output: 6

strrpos() function

Definition and usage
The strrpos() function finds where the string last appears in another string.

Returns the position if successful, otherwise returns false.

grammar
strrpos(string,find,start)

parameter describe
string Required. Specifies the string being searched.
find Required. Specifies the characters to be searched.
start Optional. Specify the location to start the search.

Tips and comments
Note: This function is case sensitive. For case-insensitive searches, use strripos().

example

Copy the codeThe code is as follows:

<?php
echo strrpos("Hello world!","wo");
?>

Output:
6

Use strrpos to verify whether the link is a link to the http protocol

Copy the codeThe code is as follows:

<?php
$url="";
if (strrpos($url, 'http://') !== 0)
echo "Link is a link to the http protocol";
?>