RE: [PHP] Extracting Numbers from a string.

From: Date: Thu, 12 Sep 2002 15:20:00 +0000
Subject: RE: [PHP] Extracting Numbers from a string.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116169@lists.php.net to get a copy of this message
that'll work because PHP will change its cast from a currency to a integery before adding. Adam On Thu, 12 Sep 2002, David Buerer wrote: > OK y'all, go ahead and shoot me, but this is what I'd do: > > $mystring="enters $56.55 for example"; > $mynumber=$mystring+1-1; > > $mynumber now equals 56.55 If you want the . to go to, use the other > methods. > > -----Original Message----- > From: Jason Caldwell [mailto:jason@thinkingman.org] > Sent: Wednesday, September 11, 2002 3:31 PM > To: php-general@lists.php.net > Subject: [PHP] Extracting Numbers from a string. > > > I need to extract the numbers only from a field. > > For example: I have an AMOUNT field and so that I can filter out any user > typo's I would like to extract the numbers only. > > If the user enters $56.55 for example or just $56 then I would like to be > able to remove the "$" and the "." keeping just the 56 or 5655. > > Can I use eregi_replace() to do this -- I've been trying but it doesn't seem > to work right. > > Thanks. > Jason > > > >

« previous php.general (#116169) next »