RE: [PHP] Stupid question

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: RE: [PHP] Stupid question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-95665@lists.php.net to get a copy of this message
>> I have a script that outputs this: >> 0.023884057998657 >> >> What's the command to make it shrink down to this: >> 0.023 >> >> I thought it was eregi() something, but I forgot. sorry > > It depends on what you need. > > If you want to round the number off to 3 decimal points use the round() > function. However if you don't want to round and instead just want to > truncate the number, the number_format() function would be what you > need. > > Sincerely, > > Craig Vincent > If speed is an issue, instead of using number_format for truncation use substr. i.e: echo substr($var, 0, 5); to get 3 dp. -- Dan Hardiker [dhardiker@staff.firstcreative.net] ADAM Software & Systems Engineer First Creative Ltd

« previous php.general (#95665) next »