0
votes

Using PHP I'm trying to echo each year since 2006 minus the current year; the result would be something like: 2006 2007 2008 2009 2010 2011 2012. I'm needing a foreach loop so I can rap each result in a <li>. I'm not sure exactly how to achieve this result.

1
Will for($i=2006; $i<date("Y"); ++$i){echo "<li>$i</li>";} work?Voitcus
What have you tried? Please post the code you have tried so far and we will give feedback. We're here to help, not to do your homework for you - try your best and we'll help you get there.Ennui

1 Answers

0
votes

take a look at DatePeriod and DateInterval

After that take a look at Negative DateInterval (KingCrunch's answer)

IMO this is the cleanest way.