All pastes #95181 Raw Edit

Mine

public php v1 · immutable
#95181 ·published 2006-07-21 20:26 UTC
rendered paste body
function strplural ( $singular ){	if(!is_str($singular))	{		throw new IncorrectArgumentException('Argument 1 ($singular) of strplural() must be a string.');		return false;	}	list($singular) = explode(' ', $singular); // get rid of unwanted other words	if(substr($singular, -2, 2) == "us")	{		$plural = substr($singular, 0, -2) . "i"; // cactus -> cacti; fungus -> fungi	}	elseif(substr($singular, -1, 1) == "s")	{		$plural = $singular . "es"; // ass -> asses (donkey of course); loss -> losses;	}	elseif(substr($singular, -1, 1) == "z")	{		$plural = $singular . "es"; // buzz -> buzzes; :S	}	elseif(substr($singular, -1, 1) == "o")	{		$plural = $singular . "es"; // potato -> potatoes; volcano -> volcanoes;	}	elseif(substr($singular, -1, 1) == "y")	{		$plural = substr($singular, 0, -1) . "ies"; // lady -> ladies; cherry -> cherries;	}	else	{		$plural = $plural . "s";	}}