Posted By

MGHollander on 10/10/12


Tagged

byte convert


Versions (?)

Byte convertor


 / Published in: PHP
 

URL: http://www.php.net/manual/en/function.ftp-rawlist.php#91120

Handy function for converting bytes to KB, MB, GB, etc.

  1. function byteconvert($bytes) {
  2. $symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
  3. $exp = floor( log($bytes) / log(1024) );
  4. return sprintf( '%.2f ' . $symbol[ $exp ], ($bytes / pow(1024, floor($exp))) );
  5. }

Report this snippet  

You need to login to post a comment.