note 81305 deleted from function.preg-match by felipe
| From: | felipe@php.net | Date: | Sun, 23 Mar 2008 22:57:33 +0000 |
| Subject: | note 81305 deleted from function.preg-match by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137385@lists.php.net to get a copy of this message | ||
Note Submitter: contact at bradjasper dot com
----
<?php
// After not being able to find a comprehensive phone number expression,
// I came up with my own which handles many ways to format a number
//
// Accepted
// 490-5473 (559) 585-1635
// (231)-826-4402 2072444529 315-789-7555 x52
// 708.333.0003 1-559-584-9639 308-882-7111 ext 7234
//
// Rejected
// 765-0600 489-4151 60-415-5389 315-789-7555, x52
function validatePhoneNumber( $sPhoneNum ) {
return preg_match('/^(1(\/|-|\s|.|))?(\(?\d{3}\)?)?(\/|-|\s|.|)?\d{3}'
. '(\/|-|\s|.|)?\d{4}(\/|-|\s|.|)?((x|ext)(.*)\d+)?$/i', $sPhoneNum );
}
?>