<?php
str strpbrk ( str $haystack , str $char_list )
where,
$haystack = The STRING where char_list is looked for
$char_list = The list of characters
?>
<?php
$par01 = 'Vir Bonus Dicendi Peritus!';
$list01 = 'usB';
$str01 = strpbrk($par01, $list01);
if ($str01)
{
echo "List of characters:<br>$list01
<br><br>Is Found in:<br>$str01";
}
else
{
echo "No character of $list01
<br>was found on<br>$par01";
}
?>
<?php
$par02 = 'Vir Bonus Dicendi Peritus!';
$list02 = 'SCENE';
$str02 = strpbrk($par02, $list02);
if ($str02)
{
echo "List of characters:<br>$list02
<br><br>Is Found in:<br>$str02";
}
else
{
echo "No character of $list02
<br>was found on<br>$par02";
}
?>
<?php
echo "Testing strpbrk() : basic functionality.
<br>- - - - - - -<br>";
function str_pbrk($one, $two) {
echo "<br>$one<br>and<br>$two<br><br>Returned value:<br>";
var_dump(strpbrk($one, $two));
echo '<br>- - - - - - -<br>';
}
// Initialise all required variables
$text = 'This is a Simple text.';
str_pbrk($text, 'mi');
str_pbrk($text, 'ZS');
str_pbrk($text, 'Z');
str_pbrk($text, 'H');
$text = '';
str_pbrk($text, 'foo');
$text = " aaa aaaSLR";
str_pbrk($text, ' ');
str_pbrk(5, 5);
str_pbrk(5, "5");
?>
<?php
$haystack = 'This is a Simple text.';
echo "Testing strpbrk()
function with empty second argument.<br><br>";
try {
strpbrk($haystack, '');
} catch (\ValueError $e) {
echo $e->getMessage() . "<br>";
}
?>