pastebin - collaborative debugging tool
kpaste.net RSS


Untitled
Posted by Anonymous on Mon 22nd Nov 2010 01:43
raw | new post

  1. <?php
  2. function mksize ($s) {
  3.         $suf = array("B", "kB", "MB", "GB", "TB", "PB");
  4.  
  5.         for ($i = 1, $x = 0; $i <= count($suf); $i++, $x++) {
  6.                 if ($s < pow(1024, $i))
  7.                         return number_format($s/pow(1024, $x), 2)." ".$suf[$x];
  8.         }
  9. }
  10.  
  11. var_dump(mksize(1024*1024*1024*1024*1024));

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at