<?php
$strings = [
'my_name_is_John_Doe',
'my_name_is john doe',
'my_name_is_john_doe',
'i_am_20_years_old',
"i'm_cool!"
];
foreach ($strings as $string) {
echo json_encode([
$string,
!strlen(ltrim($string, 'a..z_')),
!preg_match('/[a-z_]*[^a-z_]/', $string)
]);
echo "\n\n";
}
- Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- ["my_name_is_John_Doe",false,false]
["my_name_is john doe",false,false]
["my_name_is_john_doe",true,true]
["i_am_20_years_old",false,false]
["i'm_cool!",false,false]
preferences:
94.58 ms | 406 KiB | 5 Q