Jump to content

[SOLVED] function to convert number to ranking?


EchoFool

Recommended Posts

Well, you could just hijack the date function :P

 

function postFix($number)
{
$faketime = ($number * 86400) + 1230768000;
return date("S", $faketime);
}

$num = 5;
echo $num . postFix($num);

 

Output: 5th

 

Edit: Nevermind, this is stupid since it will only work for 1-31.

Oh, just FYI you can make it work with my idea.

 

function postFix($number)
{
$number = ($number > 31) ? (substr($number, -1, 1)) : $number;
if($number == 0) $number = 4;
$faketime = ($number * 86400) + 1230768000;
return date("S", $faketime);
}

for($num = 1;$num < 100;$num++)
{
echo $num . postFix($num) . '<br />';
}

 

Accurate, as far as I know.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.