Re: Question about dopping zeros

From: Date: Thu, 25 Jan 2001 23:06:42 +0000
Subject: Re: Question about dopping zeros
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36717@lists.php.net to get a copy of this message
Hello Ethan, $onum=4.11440; $onum =number_format($onum,2)+0; echo $onum; With this technique, you get the following: $onum output 4.166 4.12 4.135 4.11 4.000 4 4.3000 4.3 Is that what you wanted? To me, it's much easier to code and use than reg expressions and replaces. Best regards, Randy Thursday, January 25, 2001, 1:10:18 PM, you wrote: EN> I need to format decimals that are percise to the second place in the EN> following format: EN> 4.00 to 4 EN> 4.50 to 4.5 EN> 4.25 to 4.25 EN> As you can see, I just want to drop the trailing zeros, and if necessary the EN> decimal. EN> Thanks EN> ___________________________________ EN> Ethan Nelson, Systems Administrator EN> Net Solutions, LLC EN> 840 Lawrence Street EN> Eugene, OR 97401 EN> enelson@netsolutionsllc.com EN> http://www.netsolutionsllc.com EN> Voice +1 541 345-7087 EN> Fax +1 541 485-5519

« previous php.general (#36717) next »