number_helper.php
Go to the documentation of this file.00001 <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 if ( ! function_exists('byte_format'))
00038 {
00039 function byte_format($num)
00040 {
00041 $CI =& get_instance();
00042 $CI->lang->load('number');
00043
00044 if ($num >= 1000000000000)
00045 {
00046 $num = round($num/1099511627776)/10;
00047 $unit = $CI->lang->line('terabyte_abbr');
00048 }
00049 elseif ($num >= 1000000000)
00050 {
00051 $num = round($num/107374182)/10;
00052 $unit = $CI->lang->line('gigabyte_abbr');
00053 }
00054 elseif ($num >= 1000000)
00055 {
00056 $num = round($num/104857)/10;
00057 $unit = $CI->lang->line('megabyte_abbr');
00058 }
00059 elseif ($num >= 1000)
00060 {
00061 $num = round($num/102)/10;
00062 $unit = $CI->lang->line('kilobyte_abbr');
00063 }
00064 else
00065 {
00066 $unit = $CI->lang->line('bytes');
00067 return number_format($num).' '.$unit;
00068 }
00069
00070 return number_format($num, 1).' '.$unit;
00071 }
00072 }
00073
00074
00075