<?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"; }
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`