Hi Corinne, Maybe you have a look at the sprintf function in PHP http://www.php.net/manual/nl/function.sprintf.php It returns a string produced according to a formatting string (i.e. phonenumber) format.
Also have look at the other formatting functions in PHP. Bye, Sacha Telgenhof "Corinne Shea" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > I'd like to write a function that will take a string of characters and > output it in a phone number format (xxx)xxx-xxxx and one for credit > cards xxxx-xxxx-xxxx-xxxx. What I have below will currently remove > non-numeric characters from the string, but I'm not sure how to do the > rest of the formatting. Any help would be appreciated. > > By the way, any recommendations for good php tutorials for beginners? > > Thanks, > Corinne > > > <html> > <head> > <title></title> > </head> > > <body> > <? > function formatPhoneNum($prmValue) > { > > $retrunValue=''; > > for($i=0; $i<strlen($prmValue); $i++) > { > > if(ereg('[0-9]', substr($prmValue, $i,1))) > > $returnValue.=substr($prmValue,$i,1); > } > > return $returnValue; > > } > ?> > <? > $phoneNum= '415123kjdf4567'; > ?> > > <p>Phone Number: <?=formatPhoneNum($phoneNum)?></p> > </body> > </html> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php