note 55551 deleted from function.filesize by nlopess

From: Date: Wed, 10 Aug 2005 09:06:04 +0000
Subject: note 55551 deleted from function.filesize by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-93358@lists.php.net to get a copy of this message
Note Submitter: corychristison at lavacube dot com ---- Wouldn't it be easier to do something like this?: <?php function format_filesize( $filename ) { $filesize = filesize( $filename ); $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $pass = 0; // set zero, for Bytes while( $filesize >= 1024 ) { $filesize /= 1024; $pass++; } return round($filesize, 2) .' '. $units[$pass]; } ?> Just a thought. I wrote this to get the filesize of some log files. They are a daily log, and should not get any bigger than a few hundred MB.

« previous php.notes (#93358) next »