This seems very simple but is quite a common and complex task to tackle in PHP, so basically I'm going to show you how to add a suffix to numbers in PHP.
For example,
1 becomes 1st
73 becomes 73rd
34 becomes 34th
782 becomes 782nd
...and so on.
It's simple and can be achieved in 2 lines.
The outcome is:
It can be handy for showing things like "You are the X visitor to this website." etc.
Hope it helps.
For example,
1 becomes 1st
73 becomes 73rd
34 becomes 34th
782 becomes 782nd
...and so on.
It's simple and can be achieved in 2 lines.
PHP:
<?php
$number = 782;
$numformat = new NumberFormatter('en_GB', NumberFormatter::ORDINAL);
echo $numformat->format($number);
?>
The outcome is:
Code:
782nd
It can be handy for showing things like "You are the X visitor to this website." etc.
Hope it helps.
Last edited: