Converturea dimensiunii intr-un format usor de citit

postat acum 4 luni de Stefanescu Mihai in categorie Snippets
function HumanReadableFilesize($size) {
     // Adapted from: http://www.php.net/manual/en/function.filesize.php
     $mod = 1024;
 
    $units = explode(' ','B KB MB GB TB PB');
    for ($i = 0; $size > $mod; $i++) {
        $size /= $mod;
    }
 
    return round($size, 2) . ' ' . $units[$i];
}

 

Sunt un tanar programator din Bucuresti ce lucreaza in PHP/Mysql (MySqli/PDO), Laravel, CodeIgniter, MySQL, PostgreSQL, Wordpress, HTML5/CSS3, Sass, Photoshop si multe altele.
Google+ Community Facebook Group