Re: Re: RegEx -- help

From: Date: Fri, 10 Oct 2003 20:27:37 +0000
Subject: Re: Re: RegEx -- help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-165789@lists.php.net to get a copy of this message
On Fri, 2003-10-10 at 16:18, Curt Zirzow wrote: > On Fri, 10 Oct 2003 14:01:00 -0400 (EDT), Lists <lists@uc9.net> wrote: > > > I do not know if this is the right list, but if someone could help me > > with the following > > Sure, I'll be glad to help. > > > > I need a function that does this: > > I'm not sure if you want me to write the code that does this for you, but I > know that I wont. I'm just going to give you the tools that are commonly > used for the tasks your asking for. > > > > > function phone($num) { > > > > take num and remove anything that is not a number > > ex: () - / > > http://php.net/preg_replace > > > > > > > If there is not 1 at the start, add a one to the start of the number. > > http://php.net/substr > > > > > make sure that the number is 10 digits (if not return -1) > > http://php.net/strlen > > > } > > > > Thank you for your help, > > In the future, please at least try and attempt to write the code, most > people here arnt here to write code for everyone, but to solve problems > people are > having with their own code. Incidentally the procedure for correcting the number is flawed. If you (original poster) have a 9 digit number with an area code beginning with a 1 then the required additional 1 will never be prepended. Really what you want is if the sequence of numbers is 9 digits long then precede with a 1. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#165789) next »