/ Published in: PHP
Released into the public domain. Append $unit_sizes_bytes as you wish to allow for terabytes, petabytes, etc. (if you need that) -- each array item is an array item with the first value being the symbol for the unit and the second item being the minimum value of any file that is at least 1x that unit.
Expand |
Embed | Plain Text
function humanize_file_size($size_in_bytes) { if($size_in_bytes!=''&&strpos($size_in_bytes, '-')===false) { return '0 B'; else { $size_in_bytes = (float) $size_in_bytes; $finished = 0; for($i=0;$i<count($unit_sizes_bytes);$i++) { $finished = 1; break; } } if($finished==0) } } else return 'N/A'; }
You need to login to post a comment.
