I have been learning php in my spare time for nearly a year now but i cannot figure out how to use preg_match to validate a phone number of 11 digits. Any help will be most appreciated. Thanks in advance
hey,have a look at this page,may help you http://www.issociate.de/board/goto/797255/PHP_Phone_Number_Validation.html
Well it depends, what is the possible format? Numbers only? Spaces and numbers? If you look at the comment section of php, http://www.php.net/preg_match, you might see some phone number preg_match(...) that might help. FFMG
If you only want to validate US phone numbers, strip out all non-numeric characters, and check that the length is 11 or 10 (with/out country code). So: +1 (123) 456-7890 Becomes: 11234567890 And it is 11 digits long so it is fine. If you need something more complex, I'd look around for a better algorithm to use. It will take too much time working out all the rules and testing them yourself.
Thanks for your reply so far: What if i ant to do simple thing like validate this sort of number: 01234567890. i.e 11 digits with no special characters to separate them. Thanks
Well, this is internet isn't it, anything can happen. Ok, The truth is that i was happy and i decide to speak german. Aufdersehen