// Created on savesnippets.com ยท https://savesnippets.com/IJ2nj6f68B8TEJ 'men','woman'=>'women','child'=>'children','person'=>'people', 'tooth'=>'teeth','foot'=>'feet','mouse'=>'mice','goose'=>'geese', ]; $low = strtolower($word); if (isset($irregular[$low])) return $irregular[$low]; $last = substr($low, -1); $last2 = substr($low, -2); if (in_array($last2, ['ch','sh','ss','us','is'], true)) return $word . 'es'; if ($last === 'y' && !in_array(substr($low, -2, 1), ['a','e','i','o','u'], true)) { return substr($word, 0, -1) . 'ies'; } if ($last === 'f') return substr($word, 0, -1) . 'ves'; return $word . 's'; } echo pluralize('book', 3); // books echo pluralize('child', 2); // children echo pluralize('city', 5); // cities echo pluralize('item', 1); // item