Welcome Guest, Not a member yet? Register   Sign In
Inflector bug fix in singular()
#1

[eluser]Unknown[/eluser]
Currently, singular() results in the following:

horses -> hors
bases -> bas

I recommend the following code change in the singular() function:

Code:
$last3 = substr($str, -3);
$last4 = substr($str, -4);

if ($last3 == 'ies')
{
...
}
elseif ($last4 == 'sses')
{
...
}

Those few line changes fix the singular() function.
#2

[eluser]sophistry[/eluser]
welcome to CI CaptSaltyJack -

it's always good to come out of the gate with a bug fix! nicely done.

but...

squashing inflector bugs is like stepping on roaches... if you see one, that just means that there are 500 more in the wall and the one you saw got claustrophobia.

i suggest that you look at these threads (one has a wiki page: "inflector" - the regex he uses there is a work of art, it's really worth a peek):

http://ellislab.com/forums/viewthread/97116/
http://ellislab.com/forums/viewthread/100997/
http://ellislab.com/forums/viewthread/99938/

cheers.
#3

[eluser]Unknown[/eluser]
Ahh I see I'm not the first to notice this Smile I'll defer to the more comprehensive solutions. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB