note 112995 deleted from function.filesize by googleguy

From: Date: Fri, 16 Aug 2013 10:57:36 +0000
Subject: note 112995 deleted from function.filesize by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-195986@lists.php.net to get a copy of this message
Note Submitter: Arseny Mogilev ---- <?php /** * Converts bytes into human readable file size. * * @param string $bytes * @return string human readable file size (2,87 Мб) * @author Mogilev Arseny */ function FileSizeConvert($bytes) { $bytes = floatval($bytes); $arBytes = array( 0 => array( "UNIT" => "Тб", "VALUE" => pow(1024, 4) ), 1 => array( "UNIT" => "Гб", "VALUE" => pow(1024, 3) ), 2 => array( "UNIT" => "Мб", "VALUE" => pow(1024, 2) ), 3 => array( "UNIT" => "Кб", "VALUE" => 1024 ), 4 => array( "UNIT" => "Б", "VALUE" => 1 ), ); foreach($arBytes as $arItem) { if($bytes >= $arItem["VALUE"]) { $result = $bytes / $arItem["VALUE"]; $result = str_replace(".", "," , strval(round($result, 2)))." ".$arItem["UNIT"]; break; } } return $result; } ?>

« previous php.notes (#195986) next »