Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyvr/e2bcabeb83ddf12e3de0 to your computer and use it in GitHub Desktop.
Save jeffreyvr/e2bcabeb83ddf12e3de0 to your computer and use it in GitHub Desktop.
Validate Dutch Phone Number
<?php
/**
* Validate Dutch Phone number
*
* Can be a local or mobile phone number.
*/
function validate_dutch_phone_number( $phone_number ){
if ( preg_match( "/^(\+|00|0)(31\s?)?(6[\s-]?[1-9][0-9]{7}|[1-9][0-9][\s-]?[1-9][0-9]{6}|[1-9][0-9]{2}[\s-]?[1-9][0-9]{5})$/", $phone_number ) ) {
return true;
} else {
return false;
}
}
// Example of valid number
if( validate_dutch_phone_number( '0612345678' ) ) {
echo 'Your number is <strong>valid</strong>.';
} else {
echo 'Your number is <strong>invalid</strong>.';
}
// Example of invalid number
if( validate_dutch_phone_number( '0001' ) ) {
echo 'Your number is <strong>valid</strong>.';
} else {
echo 'Your number is <strong>invalid</strong>.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment