php - ctype_digit to only allow 10 digits starting with a 4 -
i using following function allow digits.
if (empty($vat) || (!(ctype_digit($vat)))) { $mistakes[] = 'error - title either empty or should contain numbers starting 4.';
is there way can add/modify function accept 10 digits , must start number 4?
you can use regular expressions this:
if(preg_match('/^4\d{9}$/', $vat) == 0){ $mistakes[] = 'error - title either empty or should contain numbers starting 4.'; }
and if ever need match other string or number pattern, site can test regular expression on: regexpal.com it's got pointers , tutorials , learn how match string patterns , test own regular expressions
Comments
Post a Comment