I am trying to validate an input and the rules (conditions) are:
Zero '0'
I have managed to find a solution for rule number one and the code looks like following
$str='01272095631';
if (!preg_match('/^[0-9]{11}+$/', $str)) {$error= "Yes";} else {$error= "No";}
echo $error;
Could you please help me with the rule number 2?
You are thinking to complicated. Keep things simple:
/^0[0-9]{10}$/
if (!preg_match('/^0[0-9]{10}+$/', $str)) {
$error= "Yes";
} else {
$error= "No";
}
echo $error;
Slightly reduced pattern :)
'/^0\d{10}$/'