In my contact form I've added a field where the user can send his/her phone number.
What I want to do is...
- - Since the field is not mandatory it should check if it is empty or not. if empty will send it empty
- If not empty it should check if the number start with 91, 92, 93 or 96 and it has to have 9 digits total.
if (empty($contact_phone) === true) { // send nothing... } else { //if (substr($contact_phone, 0, 2) != '91' || substr($contact_phone, 0, 2) != '92' || substr($contact_phone, 0, 2) != '93' || substr($contact_phone, 0, 2) != '96') { if(($contact_phone >= 0 && $contact_phone < 910000000 || $contact_phone >= 940000000 && $contact_phone < 960000000) || ($contact_phone >= 970000000)){ $errors[] = 'Phone numbers needs to start with 91, 92, 93 or 96. Your number: '; } }I tried those two ways but I want to know if there is another and easier way to do it.