Singular and Plural Numbered Words
Use this to get something like: “5 bananas”, “1 turtle”.
E.g. spnum(5, ‘banana’);
// Support for singular and plural string variations function spnum($int, $singular, $plural = NULL) { if (!is_int($int) || !is_string($singular)) { $int = intval($int); $singular = strval($singular); } if ($plural == NULL || !is_string($plural)) { $plural = $singular . 's'; } return $int . ' ' . (($int == 1) ? $singular : $plural); }