note 36813 deleted from function.disk-free-space by aidan

From: Date: Sat, 16 Oct 2004 00:40:32 +0000
Subject: note 36813 deleted from function.disk-free-space by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78627@lists.php.net to get a copy of this message
Note Submitter: me at no dot spam dot arkadiusz dot de ---- here is an example for calculating bytes in kb, mb, gb...etc. it's usefull to show the free/used space of big hdd's. <?php function do_bytes($size) { $kb = 1024; // Kilobyte $mb = 1024 * $kb; // Megabyte $gb = 1024 * $mb; // Gigabyte $tb = 1024 * $gb; // Terabyte if($size==0) return "n/a"; if($size < $kb) { return $size." Bytes"; } else if($size < $mb) { return round($size/$kb,2)." kb"; } else if($size < $gb) { return round($size/$mb,2)." mb"; } else if($size < $tb) { return round($size/$gb,2)." gb"; } else { return round($size/$tb,2)." tb"; } } ?>

« previous php.notes (#78627) next »