function nth_num($age, $small = 0) { $last_char_age = substr("$age", -1); switch($last_char_age) { case '1' : $th = 'st'; break; case '2' : $th = 'nd'; break; case '3' : $th = 'rd'; break; default : $th = 'th'; break; } if ($age > 10 && $age < 20) $th = 'th'; if (0 == $small) $niceage = $age.$th; if (1 == $small) $niceage = $age."$th"; return $niceage; }