The strpbrk() function behaves identically in PHP 8.4 and PHP 8.5. There are no version-specific changes or deprecations for this function in either release. The available PHP documentation and changelogs do not list any modifications to strpbrk() for PHP 8.4 or 8.5 .
Function
strpbrk() searches a string for any one of a set of characters and returns the portion of the string starting from the first character found .
Signature:
strpbrk(string $string, string $characters): string|false
Key Behavior:
- Case-Sensitive: The search is strictly case-sensitive. Searching for S will not match a lowercase is .
- Return Value: Returns a string starting from the matched character, or false if none of the specified characters are found .
Examples
Here is how you can use it in your PHP 8.4 or 8.5 projects.
1. Basic Usage (First Match Wins)
<?php
$text = This is a Simple text. ;// Searches for m OR i . The first match is i (from "This")
echo strpbrk($text, mi );
// Outputs: is is a Simple text.
?>
Because the function returns everything from the first match onwards, it finds the i in "This" before it ever reaches the m in "Simple" .
2. Case Sensitivity Demonstration
<?php
$text = This is a Simple text. ;// Searching for uppercase S matches the S in "Simple"
echo strpbrk($text, S );
// Outputs: Simple text.// Searching for lowercase is matches the first is in "This"
echo strpbrk($text, is );
// Outputs: is is a Simple text.
?>