SV: [PHP] Number formatting

From: Date: Mon, 08 Jan 2001 19:37:03 +0000
Subject: SV: [PHP] Number formatting
Groups: php.general 
Request: Send a blank email to php-general+get-33293@lists.php.net to get a copy of this message
Try this: While ($s<=strlen($string1)) { If (Ord(substr($string1, $s, 1)) >=48 AND ORD(substr($string1, $s, 1))<=57) { $string2 .= substr($string1, $s, 1); } $s++; } echo $string2; ------ $string1 is the input from the user, $string2 is only the numbers in the string. Knut G. > -----Opprinnelig melding----- > Fra: Ashley M. Kirchner [mailto:ashley@pcraft.com] > Sendt: 8. januar 2001 20:13 > Til: PHP-General List > Emne: [PHP] Number formatting > > > > I have a standard <form> page that passes the information to a PHP > script which in turn feeds the data to an mySQL database. > What I'd like > to do is have some sort of consistency in some of the fields, > especially > the phone number field. > > As people fill in their data, I'm finding out that > putting a little > command on the <form> page (stating how to enter the phone > number) gets > completely ignored, and I get stuff like this in the DB: > > 123-555-1212 > 123.555.1212 > (123) 555-1212 > (123) 555 1212 > 123) 555 1212 > 1235551212 > (123)555-1212 > 123 555 1212 > 123/555/1212 > > ...some add extra characters behind it, like 'ext' (for extension) > and 'or' (for listing a second number). However, the field in the > <form> page is just long enough for 15 characters, so they'll never be > able to enter anything more. > > Is there an easy way to convert this gibberish data into > a standard > format prior to feeding it to the DB, say (123) 555-1212 or whatever > other format I want to use? > > AMK4 > > -- > H | Hi, I'm currently out of my mind. Please leave a > message. BEEEEP! > > |____________________________________________________________________ > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Ashley M. Kirchner <mailto:ashley@pcraft.com> . > 303.442.6410 x130 > Director of Internet Operations / SysAdmin . > 800.441.3873 x130 > Photo Craft Laboratories, Inc. . eFax > 248.671.0909 > http://www.pcraft.com . 3550 > Arapahoe Ave, #6 > .................. . . . . Boulder, CO > 80303, U.S.A. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.general (#33293) next »