strpbrk() searches the haystack string for a char_list. Test strpbrk online

string strpbrk ( string $haystack , string $char_list )

PHP Documentation by the PHP Documentation Group


(PHP 5, PHP 7, PHP 8)

strpbrkSearch a string for any of a set of characters


strpbrk(string $string, string $characters): string|false

strpbrk() searches the string string for a characters.



The string where characters is looked for.


This parameter is case sensitive.

Return Values

Returns a string starting from the character found, or false if it is not found.


Example #1 strpbrk() example


'This is a Simple text.';

// this echoes "is is a Simple text." because 'i' is matched first
echo strpbrk($text'mi');

// this echoes "Simple text." because chars are case sensitive
echo strpbrk($text'S');

See Also

  • strpos() - Find the position of the first occurrence of a substring in a string
  • strstr() - Find the first occurrence of a string
  • preg_match() - Perform a regular expression match

PHP Documentation

Copyright © 1997 - 2016 by the PHP Documentation Group. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution 3.0 License or later. A copy of the Creative Commons Attribution 3.0 license is distributed with this manual. The latest version is presently available at » http://creativecommons.org/licenses/by/3.0/.