Tracks
/
PHP
PHP
/
Exercises
/
Ordinal Number
Ordinal Number

Ordinal Number

Easy

Instructions

Write a function to convert normal numbers to ordinal numbers. For zero (0) just return "0" as string.

Ordinal number are numbers that describe the position of something in a list. It is this context that ordinal numbers will be used, using an English-spelled name of an ordinal number.

The ordinal numbers are (at least, one form of them):

1st 2nd 3rd 4th 5th... 9th 10th 11th 12th... 20th 21st 22nd 23rd 24th... etc.

So entering a normal number results in its ordinal equivalent:

1 -> 1st
2 -> 2nd
3 -> 3rd
(and so on...)

Source

Explore the source of this exerciseThe link opens in a new window or tab.
Edit via GitHub The link opens in a new window or tab
PHP Exercism

Ready to start Ordinal Number?

Sign up to Exercism to learn and master PHP with 11 concepts, 114 exercises, and real human mentoring, all for free.