summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorKyle Farris <kylefarris@gmail.com>2011-03-11 23:33:05 +0100
committerKyle Farris <kylefarris@gmail.com>2011-03-11 23:33:05 +0100
commit7c6a5891c25bfdd392ed6317fd8f87b58386f030 (patch)
tree05b5c2ceaeeb53c2b53e5fc59905fa0487f72fcd /system
parent2d927761f13489187db6ae34a7c0a52367779de4 (diff)
Changed the 'plural' function so that it doesn't ruin the captalization of your string. It also take into consideration acronyms which are all caps.
Diffstat (limited to 'system')
-rw-r--r--system/helpers/inflector_helper.php11
1 files changed, 5 insertions, 6 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 4cd7486b4..3042202cb 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -82,18 +82,17 @@ if ( ! function_exists('plural'))
{
function plural($str, $force = FALSE)
{
- $str = strtolower(trim($str));
$end = substr($str, -1);
- if ($end == 'y')
+ if (preg_match('/y/i',$end))
{
// Y preceded by vowel => regular plural
- $vowels = array('a', 'e', 'i', 'o', 'u');
+ $vowels = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U');
$str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
}
- elseif ($end == 'h')
+ elseif (preg_match('/h/i',$end))
{
- if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh')
+ if(preg_match('/^[c|s]h$/i',substr($str, -2)))
{
$str .= 'es';
}
@@ -102,7 +101,7 @@ if ( ! function_exists('plural'))
$str .= 's';
}
}
- elseif ($end == 's')
+ elseif (preg_match('/s/i',$end))
{
if ($force == TRUE)
{