Page 1 of 1

PHP filesize (decimal places) hep!

Posted: Sat May 18, 2002 9:53 pm
by gotDNS
Hey, how do i use filesize() so that it only shows the file size out to 2 decimal places? PHP.net seems to be down, so anyone that can help, thanks!

Posted: Sat May 18, 2002 10:07 pm
by hob_goblin
$f_size1 = filesize($file_name);
$f_size2 = substr($f_size1, 0, 4);


might work... and $f_size2 would be the filesize only to two decimal places...

Posted: Sat May 18, 2002 10:15 pm
by hob_goblin
sorry, that was totally wrong

$size = filesize($filename);
$size = ($size/1000);
$size = round($size,2);

will put it in KB, rounding to 2 decimal places

Posted: Sun May 19, 2002 12:39 pm
by sam

Code: Select all

$size = ($size/1024);
Cheers Sam