All pastes #613511 Raw Edit

Unnamed

public text v1 · immutable
#613511 ·published 2007-07-11 00:46 UTC
rendered paste body
function number_to_english_ordinal($num) {
	$suffix = array('1'=>'st','2'=>'nd','3'=>rd');
	$worknum = $num>100 ? substr($num,-2) : $num
	 $last_digit = substr((string)$worknum, -1);
	 if (in_array($worknum,array('11','12','13'))) return $num.'th';
	return $num . (isset($suffix[$last_digit])?$suffix[$last_digit]:'th');
}