note 25435 added to function.filesize

From: Date: Mon, 23 Sep 2002 22:22:10 +0000
Subject: note 25435 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-37163@lists.php.net to get a copy of this message
A nice short human readable function: function human_readable( $number, $base=1024, $suffixes=array( " B", " KB", " MB", " GB", " TB", " PB", " EB" ) ) { $usesuf = 0; $n = (float) $number; //Appears to be necessary to avoid rounding while( $n >= $base ) { $n /= (float) $base; $usesuf++; } $places = 2 - floor( log10( $n ) ); $places = max( $places, 0 ); $retval = number_format( $n, $places, ".", "" ) . $suffixes[$usesuf]; return $retval; } -- http://www.php.net/manual/en/function.filesize.php http://master.php.net/manage/user-notes.php?action=edit+25435 http://master.php.net/manage/user-notes.php?action=delete+25435 http://master.php.net/manage/user-notes.php?action=reject+25435

« previous php.notes (#37163) next »