How to find first available alphabet in a given string?

Hi,

How to get position of first available alphabet in a given string ?
Eg. string: 9A1234

So it should return 2 (that A in on the 2nd position in the given string.)

Thanks.


$string = '9A1234';


$alpha_found = preg_match('/[a-zA-Z]/', $string, $match, PREG_OFFSET_CAPTURE);


$pos = NULL;
if( $alpha_found ) {
    $pos = $match[0][1]+1;
}

$haystack= '9A1234';
$needle= 'A';
$pos = strpos($haystack, $needle);

Hope this helps :slight_smile: