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");
?>
Try it Yourself »

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 Values

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

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");
?>
Try it Yourself »

❮ PHP String Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.