|
Posted by James Wheaton on 10/13/28 11:36
Here's a function a wrote for a previous program:
/****************************
* File size unit converter *
****************************/
function fsize_unit_convert($bytes)
{
$units = array('b', 'kb', 'mb', 'gb');
$converted = $bytes . ' ' . $units[0];
for ($i = 0; $i < count($units); $i++)
{
if (($bytes/pow(1024, $i)) >= 1)
{$converted = round($bytes/pow(1024, $i), 2) . ' ' . $units[$i];}
}
return $converted;
}
Java Boy wrote:
> 1 KB == 1024 bytes
> rest you can figure out yourself
>
> --
> Geeks Home
> www.fahimzahid.com
>
>
>
>
> "Prince of Code" <princeofcode@gmail.com> wrote in message
> news:1134977390.809166.140530@o13g2000cwo.googlegroups.com...
>> Can anybody help me out by writing a function for the given problem
>>
>> Write a function in PHP that converts given number of bytes into
>> Readabel format like 99.92 KB for 102323 bytes and
>> 3 MB for 3072 bytes and so on. Let your function be
>> sophasticated,portable,easy readable.
>>
>> Thankzz in advance
>> Napoleon
>>
--
http://www.uranther.com
Navigation:
[Reply to this message]
|