Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function human_filesize($bytes, $decimals = 2) {
$sz = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment