PHP searches a string for any function in a specified character strpbrk ()

Source: Internet
Author: User

Instance

Searches for the character "OE" in the string and returns the remainder of the string starting at the first occurrence of the specified character:

<?phpecho strpbrk ("Hello world!", "oe");? >

Definition and usage

The STRPBRK () function searches the string for any one of the specified characters.

Note: The function is case-sensitive.

The function returns the remainder of the beginning of the position where the specified character first appears. Returns FALSE if it is not found.

Grammar

STRPBRK (String,charlist)
Parameters Describe
String Necessary. Specifies the string to be searched.
Charlist Necessary. Specifies the character to find.

Technical details

return value: Returns a string that starts with the character you are looking for. Returns FALSE if it is not found.
PHP version: 5+

More examples

Example 1

The function is case-sensitive (the "W" and "W" outputs are the same):

<?phpecho strpbrk ("Hello world!", "w"), echo "<br>", Echo strpbrk ("Hello world!", "w"); >

Example

/* strpbrk. C *    /#include <string.h>  #include <stdio.h>    void main (void)  {     char string[100] = "the 3 men and 2 boys ate 5 pigs\n ";     char *result;     /* Return pointer to first ' a ' or ' B ' in "string" *     /printf ("1:%s\n", string);     result = STRPBRK (String, "0123456789");     printf ("2:%s\n", result++);     result = STRPBRK (result, "0123456789");     printf ("3:%s\n", result++);     result = STRPBRK (result, "0123456789");     printf ("4:%s\n", result);  }

Output:

1:the 3 men and 2 boys ate 5 pigs2:3 men and 2 boys ate 5 Pigs3:2 boys ate 5 pigs4:5 pigs
Related Article

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.