dannyboy1977 Posted October 21, 2006 Share Posted October 21, 2006 Hi All,I'm trying to modify my phone field php script for when a member on my site enters a phone number in a form. My script is as follows: function format_phone_data($phone_number=0) { if ($phone_number) { $PhoneNumber = ereg_replace( "[^0-9]", "", $phone_number ); // Strip out non-numerics if( ereg( "^([0-9]{3})([0-9]{3})([0-9]{4})$", $PhoneNumber, $NumberParts ) ) return "(" . $NumberParts[1] . ") " . $NumberParts[2] . "-" . $NumberParts[3]; else return $phone_number; } else return $phone_number; } //end of function format_phone_dataThis script displays the phone field as (123) 456-6789 on my websiteThis script is fine but I want to use two different phone sets. first like above (123) 456-7890 and secondly (12) 3456-7890. So when a member of my website enters 123-456-7890 in the phone field it will display as (123) 456-7890 and if they enter 12-3456-7890 it will display as (12) 3456-7890.Can anyone help me????Dan. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.