[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); } // 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); } $areacode = $matches[areacode]; $localnumber = preg_replace("/ /", "", $matches[localnumber]); $phonenumber = $areacode. "-". $localnumber; // Add Country code if needed if ($field['phone_country_code']) { $areacode = preg_replace("/^0/", "", $areacode); $phonenumber = "+31-". $areacode. "-". $localnumber; } return $phonenumber; }