Welcome Guest, Not a member yet? Register   Sign In
Convert numbers question
#1

(This post was last modified: 12-23-2017, 05:21 AM by wolfgang1983.)

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) {
 
       # size smaller then 1kb
 
       if ($size 1024) return $size ' Byte';
 
       # size smaller then 1mb
 
       if ($size 1048576) return sprintf("%4.2f KB"$size/1024);
 
       # size smaller then 1gb
 
       if ($size 1073741824) return sprintf("%4.2f MB"$size/1048576);
 
       # size smaller then 1tb
 
       if ($size 1099511627776) return sprintf("%4.2f GB"$size/1073741824);
 
       # size larger then 1tb
 
       else return sprintf("%4.2f TB"$size/1073741824);
 
   



PHP Code:
$quota imap_get_quotaroot($mbox"INBOX");

$message $quota['MESSAGE'];

$percentage = ($count $message['limit']) * 100;

echo 
round($count1) . " (" round($percentage) . "%) of " $this->byte_convert($message['limit']) . " used"
Reply


Messages In This Thread
Convert numbers question - by wolfgang1983 - 12-23-2017, 05:01 AM
RE: Convert numbers question - by Kel_Novi - 12-23-2017, 06:05 AM
RE: Convert numbers question - by Wouter60 - 12-23-2017, 06:27 AM
RE: Convert numbers question - by wolfgang1983 - 12-23-2017, 01:27 PM
RE: Convert numbers question - by PaulD - 12-23-2017, 03:54 PM
RE: Convert numbers question - by wolfgang1983 - 12-23-2017, 04:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB