3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ ')(8234@#$ABCFG3478&* hello', // mix '456456', // numeric 'ghijkl', // alphabetic '!@#$%^&*(', // non-alphanumeric ]; foreach ($strings as $string) { var_export( [ 'string' => $string, 'firstAlphaNumeric1' => preg_match('/[a-z0-9]/i', $string, $match) ? $match[0] : null, 'firstAlphaNumeric2' => $string[strcspn($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')] ?? null, 'firstAlphaNumeric3' => $string[strcspn($string, 'A..Zabcdefghijklmnopqrstuvwxyz0123456789')] ?? null, ] ); echo "\n"; }

preferences:
105.17 ms | 1472 KiB | 5 Q