protected function readableSize($size, $format = null)
	{
		// adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
		$sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');

		if(is_null($format))
		{
			$format = '%01.2f %s';
		}

		$lastsizestring = end($sizes);

		foreach ($sizes as $sizestring)
		{
			if ($size < 1024)
			{
				break;
			}

			if ($sizestring != $lastsizestring)
			{
				$size /= 1024;
			}
		}

		// Bytes aren't normally fractional
		if($sizestring == $sizes[0])
		{
			$format = '%01d %s';
		}

		return sprintf($format, $size, $sizestring);
	}
protected function readableSize($size, $format = null)
	{
		// adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
		$sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');

		if(is_null($format))
		{
			$format = '%01.2f %s';
		}

		$lastsizestring = end($sizes);

		foreach ($sizes as $sizestring)
		{
			if ($size < 1024)
			{
				break;
			}

			if ($sizestring != $lastsizestring)
			{
				$size /= 1024;
			}
		}

		// Bytes aren't normally fractional
		if($sizestring == $sizes[0])
		{
			$format = '%01d %s';
		}

		return sprintf($format, $size, $sizestring);
	}
protected function readableSize ( $ size , $ format = null ) { // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php $ sizes = array ( 'bytes' , 'kB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ) ; if ( is_null ( $ format ) ) { $ format = '%01.2f %s' ; } $ lastsizestring = end ( $ sizes ) ; foreach ( $ sizes as $ sizestring ) { if ( $ size < 1024 ) { break ; } if ( $ sizestring != $ lastsizestring ) { $ size /= 1024 ; } } // Bytes aren't normally fractional if ( $ sizestring == $ sizes [ 0 ] ) { $ format = '%01d %s' ; } return sprintf ( $ format , $ size , $ sizestring ) ; }
A helper to convert a size into a readable format

@param  int     $size
@param  string  $format
@return string
A helper to convert a size into a readable format