Strpos, STRRCHR and STRPBRK usage _php techniques for character lookup functions in PHP

Source: Internet
Author: User

This article describes the character lookup function Strpos, STRRCHR and STRPBRK usage in PHP. Share to everyone for your reference. Specifically as follows:

The ①strpos () function returns the first occurrence of a string in another string, or False if the string is not found.

Syntax: Strpos (String,find,start), code as follows:

Copy Code code as follows:
$str = "Hello World"; Definition string 1
$result =strpos ($str, "ll"); Where to find the first occurrence
echo $result; Output results, 2

The ②STRRCHR () function finds the last occurrence of a string in another string and returns all characters from that position to the end of the string, or False if it fails.

Syntax: STRRCHR (String,char), code as follows:

Copy Code code as follows:
$str = "Hello World"; Definition string 1
$result =STRRCHR ($str, "O"); Perform a lookup where the last occurrence
echo $result;

The ③STRPBRK () function searches the string for any one of the specified characters that returns the remainder of the beginning of the first occurrence of the specified character, or False if it is not found.

Syntax: STRPBRK (string,charlist), code as follows:

Copy Code code as follows:
$str = "Hello World"; Definition string 1
$result =strpbrk ($str, "oe"); Perform a Find operation
echo $result; Output results, Hello World

Tips and comments.

Note: This function is sensitive to case sensitivity.

I hope this article will help you with your PHP program design.

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.