1st, 2nd, 3rd – Adding Ordinal Number Suffix in PHP

When we need to add ordinal number suffix after normal number it become hard to manually checking the number.So I have created a function which will return a number with suffix which you can implement for multilingual context also.

First of all we need to create a array of suffix ,

Now lets build a function with two parameters where 1st parameter is the number and second parameter is language code like en. which we have used in the above $suffixes  array.By default it will take en language.

Example :

The above example  will output as :