The location of the last occurrence of a PHP lookup string in another string (case-sensitive) function Strrpos ()

Source: Internet
Author: User

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";? >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.