Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.