The strpbrk
function in PHP is used to search a string for any of a set of characters. It returns a portion of the string starting from the first occurrence of any character from the given set.
Here is the syntax of the strpbrk
function:
strpbrk(string $haystack, string $char_list): string|false
Parameters:
$haystack
: The string to search in.$char_list
: A string containing the characters to search for.Return value:
$char_list
, or false
if no character is found.Example usage:
$haystack = "Hello World";
$char_list = "aeiou";
$result = strpbrk($haystack, $char_list);
echo $result; // Output: ello World
In the above example, the strpbrk
function searches for any vowel character (a, e, i, o, u) in the $haystack
string and returns a substring starting from the first occurrence of a vowel character.
上一篇:安装php7.3(安装php8)
下一篇:php strpos
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站