summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/inflector_helper.php40
-rw-r--r--system/helpers/number_helper.php42
-rw-r--r--user_guide_src/source/helpers/inflector_helper.rst17
-rw-r--r--user_guide_src/source/helpers/number_helper.rst17
4 files changed, 58 insertions, 58 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 6dc3b5030..c71516564 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -273,3 +273,43 @@ if ( ! function_exists('is_countable'))
);
}
}
+
+// ------------------------------------------------------------------------
+
+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];
+ }
+ }
+} \ No newline at end of file
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index 20e262e66..219124cb5 100644
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -91,44 +91,4 @@ if ( ! function_exists('byte_format'))
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];
- }
- }
-}
+} \ No newline at end of file
diff --git a/user_guide_src/source/helpers/inflector_helper.rst b/user_guide_src/source/helpers/inflector_helper.rst
index df0c568c0..8a6ca7a92 100644
--- a/user_guide_src/source/helpers/inflector_helper.rst
+++ b/user_guide_src/source/helpers/inflector_helper.rst
@@ -93,4 +93,19 @@ The following functions are available:
Checks if the given word has a plural version. Example::
- is_countable('equipment'); // Returns FALSE \ No newline at end of file
+ is_countable('equipment'); // Returns FALSE
+
+.. php:function:: ordinal_format($number)
+
+ :param int $number: natural number to be converted
+ :returns: Ordinal numeral for given number or FALSE on failure
+ :rtype: string
+
+ Returns the ordinal numeral (0th, 1st, 2nd, 3rd etc.) for a
+ natural number. If the input is not a natural number, the
+ function will return boolean FALSE. Examples::
+
+ echo ordinal_format(1); // Returns 1st
+ echo ordinal_format(3); // Returns 3rd
+ echo ordinal_format(21); // Returns 21st
+ echo ordinal_format(102); // Returns 102nd
diff --git a/user_guide_src/source/helpers/number_helper.rst b/user_guide_src/source/helpers/number_helper.rst
index 47f616690..9d5e98cfb 100644
--- a/user_guide_src/source/helpers/number_helper.rst
+++ b/user_guide_src/source/helpers/number_helper.rst
@@ -49,19 +49,4 @@ The following functions are available:
echo byte_format(45678, 2); // Returns 44.61 KB
.. note:: The text generated by this function is found in the following
- language file: *language/<your_lang>/number_lang.php*
-
-.. php:function:: ordinal_format($number)
-
- :param int $number: natural number to be converted
- :returns: Ordinal numeral for given number or FALSE on failure
- :rtype: string
-
- Returns the ordinal numeral (0th, 1st, 2nd, 3rd etc.) for a
- natural number. If the input is not a natural number, the
- function will return boolean FALSE. Examples::
-
- echo ordinal_format(1); // Returns 1st
- echo ordinal_format(3); // Returns 3rd
- echo ordinal_format(21); // Returns 21st
- echo ordinal_format(102); // Returns 102nd
+ language file: *language/<your_lang>/number_lang.php* \ No newline at end of file