RE: [PHP] Need some coding help

From: Date: Sun, 15 Oct 2000 04:08:30 +0000
Subject: RE: [PHP] Need some coding help
Groups: php.general 
Request: Send a blank email to php-general+get-20196@lists.php.net to get a copy of this message
> I do not have a Perl background, so properly manipulating > strings is not my forte. I need to take a string like > "(415) 333-1234" and convert it to "4153331234". How is > this bes done with PHP? What you wanna do is nuke everything in the string that's not a number. The regular expression for "everything that is not a number" is "[^0-9]" (everything that is not between 0 and 9). $number = "(415) 333-1234"; $number = ereg_replace("[^0-9]", "", $number); ereg_replace replaces "everything that is not between 0 and 9" with "" (ie, nothing) in the variable called $number, and the reuslt is put back into $number. :) Jason

« previous php.general (#20196) next »