Instance
Find the last occurrence of "PHP" in the string:
<?phpecho Strrpos ("I love php, I love php too!", "PHP"); >
Definition and usage
The Strrpos () function finds the position of the last occurrence of a string in another string (case-sensitive).
Note: the Strrpos () function is case-sensitive.
Related functions:
Strpos ()-finds the position of the first occurrence of a string in another string (case-sensitive)
Stripos ()-finds the position of the first occurrence of a string in another string (case insensitive)
Strripos ()-Finds the last occurrence of a string in another string (case insensitive)
Grammar
Strrpos (String,find,start)
parameters |
description |
string |
required. Specifies the string to be searched. |
find |
start |
optional. Specify where to start the search. |
technical details
return value: |
Returns the position of the last occurrence of a string in another string, or FALSE if no string is found. Note: The string position starts at 0, not from 1. |
PHP version: |
4 + |
Update log: |
From PHP 5.0, the find parameter can be a string that is more than one character long.
In PHP 5.0, the start parameter has been added. |
Example:
<?php Echo Strrpos ("Hi friend!", "Fr"), whether the//strpos function can be considered as the position of the character in the string where the character is located;?>
Output results: 3
Example
<?phpecho Strrpos ("Hello world!", "Wo");? >
Output:
6
Verify that the link is a link to the HTTP protocol with Strrpos
<?php$url= "http://www.baidu.com"; if (Strrpos ($url, ' http://')!== 0) echo "link as a link to the HTTP protocol";? >