1) { $next_to_last = substr($ret, -2, 1); } else { $next_to_last = ""; } // now iterate through possibilities in a switch switch($last_digit) { case "1": // testing the second from last digit here switch($next_to_last) { case "1": $suffix ="th"; break; default: $suffix ="st"; } break; case "2": // testing the second from last digit here switch($next_to_last) { case "1": $suffix ="th"; break; default: $suffix ="nd"; } break; // if last digit is a 3 case "3": // testing the second from last digit here switch($next_to_last) { case "1": $suffix ="th"; break; default: $suffix ="rd"; } break; // for all the other numbers we use "th" default: $suffix ="th"; } // finally, return our string with it's new suffix return $pNum.KernelTools::tra( $suffix ); }