lang->load('number'); if ($num >= 1000000000000) { $num = round($num / 1099511627776, $precision); $unit = $CI->lang->line('terabyte_abbr'); } elseif ($num >= 1000000000) { $num = round($num / 1073741824, $precision); $unit = $CI->lang->line('gigabyte_abbr'); } elseif ($num >= 1000000) { $num = round($num / 1048576, $precision); $unit = $CI->lang->line('megabyte_abbr'); } elseif ($num >= 1000) { $num = round($num / 1024, $precision); $unit = $CI->lang->line('kilobyte_abbr'); } else { $unit = $CI->lang->line('bytes'); return number_format($num).' '.$unit; } return number_format($num, $precision).' '.$unit; } } // ------------------------------------------------------------------------ if ( ! function_exists('ordinal_format')) { /** * Returns the English ordinal numeral for a given number * * @param int $number * @return string */ function ordinal_format($number) { if ( ! is_numeric($number) OR $number < 0) { return FALSE; } $ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'); if ((($number % 100) >= 11) && (($number % 100) <= 13)) { return $number.'th'; } else { return $number.$ends[$number % 10]; } } }