Published in: PHP
URL: http://reusablecode.blogspot.com/2008/04/ordinal-numbers.html
<?php /* Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved. This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. */ // Returns the ordinal of a cardinal number. function ordinal($cardinal) { { return ($cardinal . 'st'); } { return ($cardinal . 'nd'); } { return ($cardinal . 'rd'); } else { return ($cardinal . 'th'); } } // Unit test. //for($i = 0; $i < 25; $i++) //{ // echo "<p>" . ordinal($i) . "</p>"; //} ?>
You need to login to post a comment.
