This is what I've tried so far:
<?php
for( $i = 1; $i <= $month_amortization; $i++ ) {
$nextmonth = date('F d, Y', strtotime('+'.$i.' month'));
$last = substr($i, -1, 1);
switch($last)
{
case "1":
$os = 'st';
break;
case "2":
$os = 'nd';
break;
case "3":
$os = 'rd';
break;
default:
$os = 'th';
}
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $nextmonth; ?></td>
<td><?php echo $i .$os . ' Monthly Amortization'; ?></td>
<td><?php echo 'PHP '. number_format($monthly_amortization, 2); ?></td>
</tr>
<?php
}
?>
This displays dates. I want to get the last date from the loop. I tried echoing $nextmonth; but I'm getting only the date today. How can I get the last date from inside the loop? Any ideas? Help is much appreciated. Thanks.