summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Farris <kylefarris@gmail.com>2011-03-12 00:34:07 +0100
committerKyle Farris <kylefarris@gmail.com>2011-03-12 00:34:07 +0100
commit2f620fe804ae5b7f4f20adc70ceaee1cf616a655 (patch)
tree36ac390b64a3e2752670d962866662e6ebfb824f
parentaf376a2df84123549293af846f827ff4da30bf5e (diff)
Fixed the capitalization "bug" in the singular function as well.
-rw-r--r--system/helpers/inflector_helper.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index e1cd66be0..c7c113b8a 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -41,20 +41,22 @@ if ( ! function_exists('singular'))
{
function singular($str)
{
- $str = strtolower(trim($str));
+ $str = trim($str);
$end = substr($str, -3);
-
- if ($end == 'ies')
+
+ $str = preg_replace('/(.*)?([s|c]h)es/i','$1$2',$str);
+
+ if (strtolower($end) == 'ies')
{
- $str = substr($str, 0, strlen($str)-3).'y';
+ $str = substr($str, 0, strlen($str)-3).(preg_match('/[a-z]/',$end) ? 'y' : 'Y');
}
- elseif ($end == 'ses')
+ elseif (strtolower($end) == 'ses')
{
$str = substr($str, 0, strlen($str)-2);
}
else
{
- $end = substr($str, -1);
+ $end = strtolower(substr($str, -1));
if ($end == 's')
{