|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by phpretard in PHP Scripting Language
I am trying to validate a phone number in this format (XXX) XXX-XXXX The code below doesn't work and is driving me nuts!
Can someone see the problem?
1:
2:
3:
4:
5:
|
$string = "(123) 456-7890";
if (preg_match('/^\(?[0-9]{3}\)?|[0-9]{3}[-. ]? [0-9]{3}[-. ]?[0-9]{4}$/', $string)) {
echo "successful.";
}
|
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625