note 66697 added to function.number-format

From: Date: Fri, 26 May 2006 10:11:28 +0000
Subject: note 66697 added to function.number-format
Groups: php.notes 
Request: Send a blank email to php-notes+get-112320@lists.php.net to get a copy of this message
Again, the function for returning file size in human readable format, but with a tweek for displaying one decimal when size is less than 10 units. <?php function human_readable( $size ) { $count = 0; $format = array("B","KB","MB","GB","TB","PB","EB","ZB","YB"); while(($size/1024)>1 && $count<8) { $size=$size/1024; $count++; } if( $size < 10 ) $decimals = 1; else $decimals = 0; $return = number_format($size,$decimals,'.',' ')." ".$format[$count]; return $return; } ?> Thanks to "php dot net at alan-smith dot no-ip dot com" and "service at dual-creators dot de". ---- Server IP: 193.27.201.10 (proxied: 193.27.201.10 1.0 www1.shellkonto.se:3128 (squid/2.5.STABLE4)) Probable Submitter: 213.66.18.237 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.number-format.php Edit -- http://master.php.net/note/edit/66697 Del: integrated -- http://master.php.net/note/delete/66697/integrated Del: useless -- http://master.php.net/note/delete/66697/useless Del: bad code -- http://master.php.net/note/delete/66697/bad+code Del: spam -- http://master.php.net/note/delete/66697/spam Del: non-english -- http://master.php.net/note/delete/66697/non-english Del: in docs -- http://master.php.net/note/delete/66697/in+docs Del: other reasons-- http://master.php.net/note/delete/66697 Reject -- http://master.php.net/note/reject/66697 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#112320) next »