Untested:
function fixhisnumber($str){ //remove all but numbers $str = preg_replace("/[^0-9]/","",$str); //append 1, unless it's already there $str = $str[0] == '1'? $str:"1".$str; if (strlen($str) == 10) return $str; else return -1; } Mohamed~ On Fri, 2003-10-10 at 14:01, Lists wrote: > I do not know if this is the right list, but if someone could help me with > the following > > I need a function that does this: > > function phone($num) { > > take num and remove anything that is not a number > ex: () - / > > > If there is not 1 at the start, add a one to the start of the number. > > make sure that the number is 10 digits (if not return -1) > > > } > > Thank you for your help, > > Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php