PHP Function Reference

PHP strpbrk() Function



The PHP strpbrk() function searches string for characters specified in charlist. This function returns a portion of the string starting from first occurrence of any of the character specified in charlist to the end of the string. If none of the specified character is found, it returns false.

Syntax

strpbrk(string, charlist)

Parameters

string Required. Specify the string where characters are looked for.
charlist Required. Specify the characters to find. This parameter is case sensitive.

Return Value

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

Example:

The example below shows the usage of strpbrk() function.

<?php
$Str = "Hello World!";

echo strpbrk($Str, "o")."\n";
echo strpbrk($Str, "OW")."\n";
?>

The output of the above code will be:

o World!
World!

❮ PHP String Reference