RSSAll Entries Tagged With: "numbers"

PHP Ordinalize Numbers – Add Suffix

Here is a very simple function to use to ordinalize numbers in PHP. This adds the place value suffix to numbers. So you can turn numbers like 1, 2, 3 into 1st, 2nd, 3rd. Here is the code: function ordinalize($int){ if(in_array(($int % 100),range(11,13))){ return $int . “th”; } else { switch(($int % 10)){ case 1: [...]

The tutorials and scripts found on bgallz.org are for training purposes only, use to your discretion.