Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<strncmpstrpos>
^String FunctionsLast updated: Mon, 26 Oct 2026

strpbrk

(PHP 5, PHP 7, PHP 8)

strpbrk — Search a string for any of a set of characters

Description

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

strpbrk() searches the string string for any of the characters in characters.

Parameters

string

The string where characters is looked for.

characters

This parameter is case sensitive.

Return Values

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

Errors/Exceptions

Throws a ValueError if characters is empty.

Changelog

Version Description
8.0.0 Now throws a ValueError if characters is empty. Previously, an E_WARNING was raised and false was returned.

Examples

Example #1 strpbrk() example

<?php

$text = 'This is a Simple text.';

// this echoes "is is a Simple text." because 'i' is matched first
echo strpbrk($text, 'mi'), PHP_EOL;

// this echoes "Simple text." because chars are case sensitive
echo strpbrk($text, 'S'), PHP_EOL;
?>

See Also

  • strpos() - Find the position of the first occurrence of a substring in a string
  • strstr() - Find the first occurrence of a string
  • preg_match() - Perform a regular expression match


<strncmpstrpos>
^String FunctionsLast updated: Mon, 26 Oct 2026