Convert numbers question |
Hi,
I want to be able to convert my KB numbers. For example the out put I am after lets say if my string is 471858 KB/MB then I would like it to change be able to echo to 0.04 GB I can't seem to get it to work for round($count, 1) What would be best way. I have tried some kb to gb converter script like but does not convert it to like 0.04GB PHP Code: function byte_convert($size) { PHP Code: $quota = imap_get_quotaroot($mbox, "INBOX");
First convert 471858 to decimal , so that would be 0.471858 then divide it by 1024 and then you will get the result of 0.04
Just a random guy from Internet
Maybe this will help:
PHP Code: function byte_convert($size,$unit='MB',$decimals=2) { Call the function like this: PHP Code: echo byte_convert(150000000,'TB',4);
(12-23-2017, 06:27 AM)Wouter60 Wrote: Maybe this will help: I tried this $this->format_size($count, 'GB') PHP Code: function format_size($size, $unit = 'MB', $decimals = 2) { My all the total of my email sizes are 471858 But only returns 0.00 GB not 0.04 GB
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
471858 bytes is 0.0004 GB. So the function is returning the correct figure to 2 decimal places.
(12-23-2017, 03:54 PM)PaulD Wrote: 471858 bytes is 0.0004 GB. So the function is returning the correct figure to 2 decimal places. OK so will have to change a couple of things cool bit more practice for me
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |