PHP Schnipsel

Byte umrechner

Das Schnipsel rechnet Bytes in KB und MB um.

Drucken
  1.  <?   
  2.     
  3.  function byte_calculation($bytes) {   
  4.   if ($bytes pow(2,10)) {   
  5.    if ($bytes pow(2,20)) {   
  6.     $size number_format(($bytes/pow(2,20)),2);   
  7.     $size .= " MB"  
  8.     
  9.      return $size  
  10.    } else {   
  11.     $size number_format(($bytes/pow(2,10)),2);   
  12.     $size .= " KB"  
  13.     return $size  
  14.      
  15.   } else {   
  16.    $size = (string) $bytes " Bytes"  
  17.     
  18.     return $size  
  19.     
  20.    
  21.        
  22.     // 10000 Bytes   
  23.     echo byte_calculation(10000);   
  24.     
  25.     echo "<BR>"  
  26.     
  27.     // 20000000 Bytes   
  28.     echo byte_calculation(20000000);   
  29.     
  30.  ?>    






T: 34979 G: 7 H: 10 T: +4 O: 6