PHP strpbrk() Function

Example

Search for the character "Sh" in the string and return the remaining part starting from the position of the first occurrence of the specified character in the string:

<?php
echo strpbrk("I love Shanghai!","Sh");
?>

Run Instances

Definition and Usage

The strpbrk() function searches for any of the specified characters in the string.

Note:This function is case-sensitive.

This function returns the remaining part starting from the position of the first occurrence of the specified character. If failed, returns FALSE.

Syntax

strpbrk(string,charlist)
Parameters Description
string Required. Specifies the string to be searched.
charlist Required. Specifies the character to be searched for.

Technical Details

Return Value: Returns the string starting from the character found. If not found, returns FALSE.
PHP Version: 5+

More Examples

Example 1

This function is case-sensitive (output of "S" and "s" is different):

<?php
echo strpbrk("I love Shanghai!","S");
echo "<br>";
echo strpbrk("I love Shanghai!","s");
?>

Run Instances