A function to add a prefix to numbers ex. 1st 2nd 3rd 4th 5th
Copy this code and paste it in your HTML
function ordinalize($number) {
return $number.'th';
}else{
switch (($number % 10)) {
case 1:
return $number.'st';
break;
case 2:
return $number.'nd';
break;
case 3:
return $number.'rd';
default:
return $number.'th';
break;
}
}
}
Report this snippet
Comments
Subscribe to comments