Permalink
Browse files

- initial import

  • Loading branch information...
1 parent 2f0c5a3 commit 12b4f9ddfec8aae848862fb879fb240b87286a88 @pierrejoye pierrejoye committed Apr 30, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 include/tools.php
View
@@ -0,0 +1,9 @@
+<?php
+function bytes2string($size, $precision = 2) {
+ $sizes = array('YB', 'ZB', 'EB', 'PB', 'TB', 'GB', 'MB', 'kB', 'B');
+ $total = count($sizes);
+
+ while($total-- && $size > 1024) $size /= 1024;
+
+ return round($size, $precision).$sizes[$total];
+}

0 comments on commit 12b4f9d

Please sign in to comment.