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