English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String String Function Manual
The strpbrk() function is used to search for any character in the specified character set within a string.
string strpbrk ( string $haystack , string $char_list )
The string used to find specific characters. That is, find the characters in the char_list within the haystack string.
Returns a substring starting with the found character. If not found, returns FALSE.
Serial Number | Parameters and Description |
---|---|
1 | haystack Required. It specifies the first string to be searched |
2 | charlist Required. It specifies the list of characters to be searched |
Try the following example, search for the character "hn" in the string and return the remaining part of the string starting from the first occurrence of the specified character:
<?php //Find 'hn' in the string, 'n' is matched first, return the result echo strpbrk("www.oldtoolbag.com","hn"); echo '<br>'; //Find the capital I letter in the string and return the result echo strpbrk("input Input","I"); echo '<br>'; $text = 'This is a Simple text.'; // Output "is is a Simple text." because 'i' is matched first echo strpbrk($text, 'mi'); echo '<br>'; // Output "Simple text." because characters are case-sensitive echo strpbrk($text, 'S'); ?>Test and see‹/›
oldtoolbag.com Input is is a Simple text. Simple text.PHP String String Function Manual