From a6aabaff9a396436d36b57df84eec77ee72e70ed Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 10 Feb 2009 17:37:52 +0000 Subject: Fixed a bug in plural() with words that end in y http://codeigniter.com/bug_tracker/bug/6342/ --- system/helpers/inflector_helper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 9393f11e4..39db5d4af 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -87,7 +87,9 @@ if ( ! function_exists('plural')) if ($end == 'y') { - $str = substr($str, 0, strlen($str)-1).'ies'; + // Y preceded by vowel => regular plural + $vowels = array('a', 'e', 'i', 'o', 'u'); + $str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies'; } elseif ($end == 's') { -- cgit v1.2.3-24-g4f1b