Something Different After looking at different solutions, I thought it would be better to just use the functions built into PHP. Not sure if this is more efficient, but it's certainly less code and works every time. <?php function ordinal($int) { $two = substr($int, -2); $day = $two < 32 ? $two : '2' . substr($two, -1); $suffix = date('S', strtotime('May ' . $day)); return $int . $suffix; } ?> Reply
After looking at different solutions, I thought it would be better to just use the functions built into PHP. Not sure if this is more efficient, but it's certainly less code and works every time.
<?php
function ordinal($int)
{
$two = substr($int, -2);
$day = $two < 32 ? $two : '2' . substr($two, -1);
$suffix = date('S', strtotime('May ' . $day));
return $int . $suffix;
}
?>