strpbrk() – PHP String Functions
Syntax :
Description :
strpbrk() function will searches a string for any of the specified characters.
Note : case-sensitive function.
Parameter :
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|left|left|left”]
Name, Required /Optional, Value Type, Description
string, Required, String, It is the string in which search will take place.
char_list, Required, String, It species the characters list that is to be search in the string.
[/table]
Output :
It returns the remaining string from where the first occurrence of the char_list is found in the string and Otherwise it returns FALSE.
Related articles : strpos(), strstr().
strpbrk() – PHP Functions Example 1 :
This will start outputting from “m tutorialmines.” because it will find “m” character first occurrence and return the string from their only.
<?php // case-sensitive echo strpbrk("Hi from tutorialmines.","tm"); ?>
Output of above code in the browser is as below:
strpbrk() – PHP Functions Example 2 :
It returns FALSE if char_list is not found in string. See in example for letter “T”. But for letter “f” it returned the string from the point where it is found.
<?php var_dump(strpbrk("Hi from tutorialmines.","T")); // return FALSE if char_list is not found in string echo "<br/>"; echo strpbrk("Hi from tutorialmines.","f"); ?>
Output of above code in the browser is as below:
<br/>
from tutorialmines.