PHP Newsletter

Join now and receive weekly updates pertianing to the world of PHP.

Polls

What do you think about the new PHPMine Design?
Awesome
Not Bad
Sucks

PHP Gigs By City

PHP Jobs By Topic

Advertisements

help me with my php scripting?

Asked 2010-03-07 22:18:18 by Adam

--------------------------------
<em><?=round( filesize($leadon.$files[$i])/1024 );?>KB</em>
--------------------------------

in the above code, how can i change KB into MB and round to 2 decimals? I found the below code which says it does it but i have no idea how to replace the above to include it... Also, I know instead of 1024 i'd need 1048576 (i think).

--------------------------------
float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] )
--------------------------------
THANK YOU Colanth, it worked like a charm! I'll get u yr points once yahoo lets me choose best answer. ;P

Anwered 2010-03-07 22:29:41 by Colanth

<em><?= round(filesize($leadon.$files[$i]) / 1048576, 2);?>MB</em>

I didn't run it (it's a bit of a pain to save it to a file, upload it to my local server, give it a value, etc.), but it should work. (The spaces around the division sign - ) / 1048576 - are just to keep Yahoo from eating characters.)

Questions and answers provided by the Yahoo Answers Community.