note 80290 modified in function.filesize by danbrown

From: Date: Sun, 18 Jan 2009 18:03:20 +0000
Subject: note 80290 modified in function.filesize by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149399@lists.php.net to get a copy of this message
This script checks whether the file is large enough for the next unit and calculates them. Example: 29249 bytes => 28.56 KB 10083695 bytes => 9.62 MB <?php function get_size($size) { $bytes = array('B','KB','MB','GB','TB'); foreach($bytes as $val) { if($size > 1024){ $size = $size / 1024; }else{ break; } } return round($size, 2)." ".$val; } ?> --was-- This script checks whether the file is large enough for the next unit and calculates them. Example: 29249 bytes => 28.56 KB 10083695 bytes => 9.62 MB function get_size($size) { $bytes = array('B','KB','MB','GB','TB'); foreach($bytes as $val) { if($size > 1024){ $size = $size / 1024; }else{ break; } } return round($size, 2)." ".$val; } http://php.net/manual/en/function.filesize.php

« previous php.notes (#149399) next »