function valid_nl_phone_number in Phone 7
Same name and namespace in other branches
- 6 phone.nl.inc \valid_nl_phone_number()
Verifies that $phonenumber is a valid ten-digit Dutch phone number with spaces and -
Regular expression adapted from Nico Lubbers's regex at RegExLib.com
Parameters
string $phonenumber:
Return value
boolean Returns boolean FALSE if the phone number is not valid.
File
- include/
phone.nl.inc, line 23 - CCK Field for Dutch phone numbers.
Code
function valid_nl_phone_number($phonenumber) {
//$phonenumber = trim($phonenumber);
/*
Accepts:
06-12345678
06 123 456 78
010-1234567
020 123 4567
0221-123456
0221 123 456
Rejects:
05-12345678
123-4567890
123 456 7890
*/
// define regular expression
$regex = '/
([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]{1}[-\\s]+[1-9]{1}[\\s]*([0-9]{1}[\\s]*){6}) # Phonenumber with 3 digit area code
/x';
// return true if valid, false otherwise
return (bool) preg_match($regex, $phonenumber);
}