I'd like to add the following text to a page in Wordpress: "Gina is now in her 16th (or sixteenth) year at the company," where 16th is a calculation based on her start year.
I know how to calculate her number of years at the company using PHP echo:
<?php echo date("Y")-1998 ?>
I also know that there are functions that can be used to attach a suffix to the number, such as:
<?php
$ends = array('th','st','nd','rd','th','th','th','th','th','th');
if (($number %100) >= 11 && ($number%100) <= 13)
$abbreviation = $number. 'th';
else
$abbreviation = $number. $ends[$number % 10];
?>
What I don't know how to do is put these two things together and have them output properly on a Wordpress page. My knowledge of PHP is pretty basic so I'm hoping someone out here might have the answer. Thanks!