Created
January 20, 2015 07:37
-
-
Save hipsterjazzbo/54e06d4ef79c61f2a19b to your computer and use it in GitHub Desktop.
Example of `elseif`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Pass in a number and get it back as a string with an ordinal suffix (1 -> 1st, 2 -> 2nd etc) | |
*/ | |
function addSuffix($number) | |
{ | |
if ($number == 1) { | |
return $number + 'st'; | |
} elseif ($number == 2) { | |
return $number + 'nd'; | |
} elseif ($number == 3) { | |
return $number + 'rd'; | |
} else { | |
return $number + 'th'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment