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 ( ! ctype_digit((string) $number) OR $number < 0) { return FALSE; } $last_digit = array( 0 => 'th', 1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th', 5 => 'th', 6 => 'th', 7 => 'th', 8 => 'th', 9 => 'th' ); if (($number % 100) >= 11 && ($number % 100) <= 13) { return $number.'th'; } else { return $number.$last_digit[$number % 10]; } } }