Re: Converting a String to Int

From: Date: Wed, 09 Apr 2003 09:08:54 +0000
Subject: Re: Converting a String to Int
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-143029@lists.php.net to get a copy of this message
On Wed, 2003-04-09 at 01:51, Jason Wong wrote: > On Wednesday 09 April 2003 02:21, Poon, Kelvin (Infomart) wrote: > > [snip] > > > I get a number that is wrong because > > $num isn't an integer, I am guessing it has to do with the comma (3,469) in > > $num. Can I convert $num=3,469 into an int? If not, can I maybe take out > > the comma and then convert it to int? Please help > > str_replace() the comma with nothing. Sorry, but this won't work. It will return a string. Instead, you should use intval() -- which will return the desired result. $val = intval($num); http://www.php.net/intval -- Burhan Khalid phplist[at]meidomus[dot]com Please add a reply-to: header in your messages that points to the mailing list address so that all mail is properly archived and viewed.

« previous php.general (#143029) next »