Jump to content

Number order?


woolyg

Recommended Posts

Sorry, I picked 30 as an example - these numbers could go up to any number really. I found a nice little function from reading a bit further:

 

 

function ordinalize($number) {
     if (in_array(($number % 100),range(11,13))){
         return $number.'th';
         }else{
     switch (($number % 10)) {
     case 1:return $number.'st';
     break;
     case 2:
     return $number.'nd';
     break;
     case 3:return $number.'rd';
     default:return $number.'th';
     break;
         }
     }
}

 

Thanks for your help!

- Woolyg

 

Link to comment
https://forums.phpfreaks.com/topic/101503-number-order/#findComment-519216
Share on other sites

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.