Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hipsterjazzbo
Created January 20, 2015 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hipsterjazzbo/54e06d4ef79c61f2a19b to your computer and use it in GitHub Desktop.
Save hipsterjazzbo/54e06d4ef79c61f2a19b to your computer and use it in GitHub Desktop.
Example of `elseif`
<?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