92 of 410 menu

The strpbrk Function

The strpbrk function searches a string for any given character and returns the string starting from the found character, or false if it was not found.

Syntax

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

Example

In this example, the function searches for characters 's' or 'i', finds the first one encountered and returns the rest of the string:

<?php echo strpbrk('lorem ipsum dolor sit amet', 'si'); ?>

Code execution result:

'ipsum dolor sit amet'

See Also

  • the strstr function,
    which finds the first occurrence of a substring
byenru