diff --git a/include/phone.nl.inc b/include/phone.nl.inc index 781790f..3627f65 100644 --- a/include/phone.nl.inc +++ b/include/phone.nl.inc @@ -27,8 +27,11 @@ function valid_nl_phone_number($phonenumber) { /* Accepts: 06-12345678 + 0612345678 06 123 456 78 010-1234567 + 0101234567 + 010123 4567 020 123 4567 0221-123456 0221 123 456 @@ -40,11 +43,11 @@ function valid_nl_phone_number($phonenumber) { // define regular expression $regex = '/ - ([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7}) # Mobile phonenumber + ([0]{1}[6]{1}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){7}) # Mobile phonenumber | - ([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5}) # Phonenumber with 4 digit area code + ([0]{1}[1-9]{1}[0-9]{2}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){5}) # Phonenumber with 4 digit area code | - ([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6}) # Phonenumber with 3 digit area code + ([0]{1}[1-9]{1}[0-9]{1}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){6}) # Phonenumber with 3 digit area code /x'; // return true if valid, false otherwise @@ -61,16 +64,16 @@ function format_nl_phone_number($phonenumber, $field) { $areacode = $localnumber = ''; // Mobile number - if (preg_match('/([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber)) { - preg_match('/([0]{1}[6]{1})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber, $matches); + if (preg_match('/([0]{1}[6]{1}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber)) { + preg_match('/([0]{1}[6]{1})[-\s]*([1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber, $matches); } // Phonenumber with 4 digit area code - if (preg_match('/([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber)) { - preg_match('/([0]{1}[1-9]{1}[0-9]{2})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber, $matches); + if (preg_match('/([0]{1}[1-9]{1}[0-9]{2}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber)) { + preg_match('/([0]{1}[1-9]{1}[0-9]{2})[-\s]*([1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber, $matches); } // Phonenumber with 3 digit area code - if (preg_match('/([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber)) { - preg_match('/([0]{1}[1-9]{1}[0-9]{1})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber, $matches); + if (preg_match('/([0]{1}[1-9]{1}[0-9]{1}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber)) { + preg_match('/([0]{1}[1-9]{1}[0-9]{1})[-\s]*([1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber, $matches); } $areacode = $matches[1];