<?php
$strings = [
'A number at the end 1357',
'2368 Letters and spaces 8675309',
];
foreach ($strings as $string) {
var_export([
'strcspn' => strcspn($string, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '), //reduces to 'a..zA..Z '
'strspn' => strspn($string, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '), //reduces to 'a..zA..Z '
'strpbrk' => strpbrk($string, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '), //reduces to 'a..zA..Z '
'strtok' => strtok($string, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '), //reduces to 'a..zA..Z '
'strtok2' => strtok('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '), //reduces to 'a..zA..Z '
]);
echo "\n--\n";
}
- Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- array (
'strcspn' => 0,
'strspn' => 20,
'strpbrk' => 'A number at the end 1357',
'strtok' => '1357',
'strtok2' => false,
)
--
array (
'strcspn' => 4,
'strspn' => 0,
'strpbrk' => ' Letters and spaces 8675309',
'strtok' => '2368',
'strtok2' => '8675309',
)
--
preferences:
121.47 ms | 403 KiB | 121 Q