Advertisement
reenadak

function filesize

Sep 25th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. // remainder
  2. //echo date('d');
  3.  
  4. echo fmod(date('d'), 6);
  5. // fmod return the remainder.
  6.  
  7. // function filesize
  8. function niceSize($size)
  9. {
  10.    
  11.     define("SIZESTEP", 1024.0);
  12.    
  13.     static $sizeUnits = Array(" B","KB","MB","GB","TB","PB","EB");
  14.    
  15.     if($size==="") return "";
  16.    
  17.     $unitIndex = 0;
  18.  
  19.     while($size>SIZESTEP)
  20.     {
  21.         $size = $size / SIZESTEP;
  22.         $unitIndex++;
  23.     }
  24.    
  25.     if($unitIndex==0) {
  26.         return number_format($size, 0)." ".$sizeUnits[$unitIndex];
  27.     } else {
  28.         return number_format($size, 1, ".", ",")." ".$sizeUnits[$unitIndex];
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement