-
Rounding numbers in PHP?
Hi,
I want to know hoe to round numbers in php?
I have a script that gets a file size, then divides it by 1000 to get it into KB, however its like:
94.578 KB
How do I make it so it would say:
95 KB or 94.6 KB ?
Thanks in advance.
One last question.. I also have the expected time to download it, but Im using an average download rate of 3.5 KB, cos I dont know how to get his current dl rate, or if its even possible, so i asked my friends what their average dl rate was and 3kb seems about average.. Obviously broadband users will have quicker dl rates, but if you have broadband nothing takes long to download ;)
Can you get the average dl rate?
Or is there a way by checking their connection and server speed you can predict the download rate?
Cheeko
-
double round (double val [, int precision])
Returns the rounded value of val to specified precision (number of digits after the decimal point).
$foo = round (3.4); // $foo == 3.0
$foo = round (3.5); // $foo == 4.0
$foo = round (3.6); // $foo == 4.0
$foo = round (1.95583, 2); // $foo == 1.96
as far as telling the dl speed is, if they are on modem look at what they connect at, say 52,000 then generally it would be 5.2k/s or 48,000 is 4.8k/s if it says 115,000 then go to a site that you know is fast and download something. that way you can see what it is.