Logo
Add (th, st, nd, rd, th) to the end of a number
Online Now: 2
Snippet Code
This simple and easy function will take a number and add "th, st, nd, rd, th" after it. Example 10 to 10th.
<?php
function ordinal($cdnl){
    
$test_c abs($cdnl) % 10;
    
$ext = ((abs($cdnl) %100 21 && abs($cdnl) %100 4) ? 'th'
            
: (($test_c 4) ? ($test_c 3) ? ($test_c 2) ? ($test_c 1)
            ? 
'th' 'st' 'nd' 'rd' 'th'));
    return 
$cdnl.$ext;

for(
$i=1;$i<100;$i++){
    echo 
ordinal($i).'<br>';
}
?>
 
Snippet Comments

Add Your Comment

jeux de foot
2011-06-29 05:44:35
just wanna say this post is fantastic.. it contain sach a valuable information. you have done a brilliant job.
Juegos de Bob Esponja
2011-06-29 05:40:31
it contains lot of information. I always prefer to read the quality content and this thing I found in you post. I really enjoyed reading this.
moving company in Washington DC
2011-06-29 02:26:32
In most web applications there will be some restricted content – whether that is administrative functions such as managing contents Thanks for sharing the nice post.
Round Rock Real Estate
2011-06-28 12:58:35
I search in google related to this topic and I found your site. This is not I wanted but it seems so nice to me so I read it. This site is full of informative ideas. Thanks for sharing this.
Steiner Ranch Homes
2011-06-28 00:51:59
I am very glad that I find your regular post here. Which seems to be very important and it made good time pass for me. I will always give a nice thrust look in to you from my bookmark feed. I don't actually comment and don't like to spend time in typing the comment. But here I have to do this because this deserves a good like.
New Homes Austin TX
2011-06-28 00:30:28
Mais attention aux mauvaises cartes : Ouattara ne peut indéfiniment ouvrir seulement les cartes "chance" distribuées par la France, il faut des résultats, maintenant ! La "communauté internationale" est impatiente de prouver rapidement au monde que "son choix" est celui des ivoiriens, que les méchants seront punis par la très sérieuse CPI, et que l'avenir radieux auquel les ivoiriens virtuels du tandem Sarkozy -Ouattara aspirent est encore à portée demain
gaurav
2011-06-28 00:27:39
Il est presque impossible de trouver des détails sur cette dame très âgée, madame Koudou Gbagbo, âgée de plus de 90 ans -92, ai-je lu une fois-, et à qui rien n'a été épargné. Selon certaines sources, son arrestation ne s'est pas faite en douceur, et c'est probablement très discrètement qu'elle a été "libérée", sachant que ses jours étaient comptés.
Seo Orlando
2011-06-27 22:20:59
This is a public source code repository where you can find, rate and comment code snippets published by others.
Office cleaning Elmhurst
2011-06-27 06:36:32
will surely treasure this one of a kind site.Keep posting informative post!This was really cool.
link building campaign
2011-06-25 20:22:18
Hmmm ...,, the title of this post, made me feel interested. I am interested in your reasons why you need to make posts like this.
ways to make money fast
2011-06-25 17:09:33
The typos are the common mistakes that people make while trying to insert a website, by registering the popular typos Thanks for sharing the information.
how to get rid of stretch marks
2011-06-23 22:47:24
I was so amaze on this one .I will surely treasure this one of a kind site.Keep posting informative post!This was really cool.
how to get rid of a hickey
2011-06-23 22:46:36
This is an amazing post and I can believe that this type of write is very useful.
timrude
2011-06-23 16:07:30
Good
timrude
2011-06-23 16:04:32
My pleasure is the thing
Mulberryee
2011-06-22 05:28:50
The user-friendly design allows you to carry Mulberry Alexa Holdall or shoulder bag 0303 with its handle and a shoulder bag across your body.Our Mulberry Bags.
SEO
2011-06-22 01:42:29
Anyway, in my language, there usually are not much good supply like this.
custom logo design
2011-06-21 23:51:31
I agreed This simple and easy function will take a number and add "th, st, nd, rd, th" after it.
Orlando Managed services
2011-06-21 18:45:57
There is so much great work that went into this. The ideas behind this is so good. Keep up the good work.
Pioneer AVH-P4200DVD
2011-06-21 05:07:43
Thanks for this code, you're a life saver. Still learning the ropes as far as PHP goes and this saved me a ton of time.

Add Your Comment

 
Snippet Tools
Rate this Snippet:

Rate the difficulty level:

Request Snippet Update


Suggested Difficulty Level: Novice
Current Score: 3.31
Total votes: 403
Total Views: 27050

Other top snippets by admin:

1. JPEG to ASCII Converter
2. Dynamic Page Content From Links
3. AJAX Quickie
4. Simple Image CAPTCHA
5. Logout Inactive User

Search
Search for:







User Panel

User name:

Password:

Register And Post Your Own Snippets

New Snippets

1.  Shorten text and (4 of 1)

2.  file-based simple guest (0 of 0)

3.  adding an entry (0 of 0)

4.  integer to currency (1.33 of 3)

5.  Aggregate IP addresses (0 of 0)

6.  file handling (0 of 0)

7.  testing system with (0 of 0)

8.  Make an php (1 of 1)

9.  allow download in (5 of 1)

10.  redirect in 3 (0 of 0)

11.  live clock with (0 of 0)

12.  visit counter (3.5 of 2)

13.  contact form with (4 of 1)

14.  show a specific (0 of 0)

15.  The & sign (0 of 0)

16.  static variable in (0 of 0)

17.  multiplication table with (0 of 0)

18.  function with multiplicationt (0 of 0)

19.  php generated menu (0 of 0)

20.  drawing a table (0 of 0)

21.  embedded array (one (0 of 0)

22.  checks the week (0 of 0)

23.  put links on (4.5 of 2)

24.  Directory Image Gallery (0 of 0)

25.  TOS (4 of 1)

Home | Forum | Free PHP Web Hosting | Contact | Terms & Conditions |  
Donate
PHPSnips.com - ©2012 Amethyst Creative