note 101400 added to function.filesize
| From: | Anonymous at osu1 dot php dot net | Date: | Wed, 15 Dec 2010 00:10:39 +0000 |
| Subject: | note 101400 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174926@lists.php.net to get a copy of this message | ||
bconvert(345324535345); // return: 321 Gb 623 Mb 143 Kb 561 b
function bconvert($bytes)
{
static $typetext = array('Kb','Mb', 'Gb', 'Tb');
static $typesize = array(1024, 1048576, 1073741824, 1099511627780);
$num = 3;
$total_txt = '';
$cur_num = 0;
$success = 0;
while(true)
{
if($typesize[$num] <= $bytes)
{
$bytes -= $typesize[$num];
$cur_num++;
$success = 1;
}
else
{
if($success)
{
$total_txt .= $cur_num.' '.$typetext[$num].' ';
$cur_num = 0;
$success = 0;
}
$num--;
if($typesize[0] > $bytes)
{
if($bytes != 0)
$total_txt .= $bytes.' b';
break;
}
}
}
return $total_txt;
}
----
Server IP: 69.147.83.197
Probable Submitter: 89.208.127.241
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- https://master.php.net/note/edit/101400
Del: integrated -- https://master.php.net/note/delete/101400/integrated
Del: useless -- https://master.php.net/note/delete/101400/useless
Del: bad code -- https://master.php.net/note/delete/101400/bad+code
Del: spam -- https://master.php.net/note/delete/101400/spam
Del: non-english -- https://master.php.net/note/delete/101400/non-english
Del: in docs -- https://master.php.net/note/delete/101400/in+docs
Del: other reasons-- https://master.php.net/note/delete/101400
Reject -- https://master.php.net/note/reject/101400
Search -- https://master.php.net/manage/user-notes.php