Current Location: Home> Function Categories> strpbrk

strpbrk

Find any one of a set of characters in a string - Return a substring that starts with the found character
Name:strpbrk
Category:String
Programming Language:php
One-line Description:Find any character of a set of characters in a string.

Example

Example 1

Search for the character "Sh" in the string and return the remaining part of the string starting from where the specified character first appears:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strpbrk</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"I love Shanghai!"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"Sh"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

Try it yourself

Example 2

This function is case sensitive (the output of "S" and "s" are not the same):

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strpbrk</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"I love Shanghai!"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"S"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token string double-quoted-string">"<br>"</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token function">strpbrk</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"I love Shanghai!"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"s"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

Try it yourself

Similar Functions
Popular Articles