You are here: Re: File Size Conversion « PHP Programming Language « IT news, forums, messages
Re: File Size Conversion

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация