THE WORLD'S LARGEST WEB DEVELOPER SITE

PHP strpbrk() Function

❮ PHP String Reference

Example

Search a string for the characters "oe", and return the rest of the string from where it found the first occurrence of the specified characters:

<?php
echo strpbrk("Hello world!","oe");
?>
Run example »

Definition and Usage

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

Note: This function is case-sensitive.

This function returns the rest of the string from where it found the first occurrence of a specified character, otherwise it returns FALSE.


Syntax

strpbrk(string,charlist)

Parameter Description
string Required. Specifies the string to search
charlist Required. Specifies the characters to find

Technical Details

Return Value: Returns the string starting from the character found, otherwise it returns FALSE
PHP Version: 5+

More Examples

Example 1

This function is case-sensitive ("W" and "w" will not output the same):

<?php
echo strpbrk("Hello world!","W");
echo "<br>";
echo strpbrk("Hello world!","w");
?>
Run example »

❮ PHP String Reference