Anonymous

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;
}
?>

Fri, 31/08/2012 - 00:54 Permalink

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <p> <br> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA