check if number has 4 digits php code example Example: validate number should by 12 digit in php /^$|^[0-9]{12}$/