Recently, I had to delete enormous amounts of code which I had painstakingly coded but which already existed inside PHP. For example, I had a function to spell out numbers, such as "56" => "fifty-six". PHP has this built in, supporting any locale/language. It was much better than my built-in function. Example:
$a = new \NumberFormatter('en_US', \NumberFormatter::SPELLOUT);
var_dump($a->format('3'));
Outputs:
three
Now I'm potentially facing this issue again. I don't want to hardcode in 1 => "1st", 2 = "2nd", 3 = "3rd", 4 = "4th", etc. as English, only to then find out that PHP can do it automatically for any language! Is that the case?
To be extremely clear, I want to input "2" to a function and have it spit out "2nd" if the locale is en_US, and whatever else if a different language/locale, as appropriate.