Strposstrrchrstrpbrk character search function in php

Source: Internet
Author: User
In php, the strposstrrchrstrpbrk character search function strpos () returns the position where the string first appears in another string. if the string is not found, false is returned.

Syntax: strpos (string, find, start). The code is as follows:

$ Str = "hello world"; // defines string 1

$ Result = strpos ($ str, "ll"); // execute the following command to find the earliest location

Echo $ result; // output result, 2

The strrchr () function is used to locate the last occurrence position of a string in another string and return all characters from this position to the end of the string. if the result fails, false is returned.

Syntax: strrchr (string, char). The code is as follows:

$ Str = "hello world"; // defines string 1

$ Result = strrchr ($ str, "o"); // run the following command to find the last position.

Echo $ result;

The strpbrk () function searches for any of the specified characters in a string. This function returns the remainder of the position at which the specified character first appears. if not found, false is returned.

Syntax: strpbrk (string, charlist). The code is as follows:

$ Str = "hello world"; // defines string 1

$ Result = strpbrk ($ str, "oe"); // perform the search operation.

Echo $ result; // output result, ello world

// Open source code phpfensi.com

Prompt and comment.

Note: This function is case sensitive.

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.