phpretard Posted March 29, 2009 Share Posted March 29, 2009 I need to display the current year + 5 more. Here is what I have... $EXPYear=date(Y); for ($i=$i; $i <= 5; $i++){ echo <option>This Year And Five More</option>; } Obviously doesn't work... Thank you! Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 29, 2009 Author Share Posted March 29, 2009 Not Simple? Quote Link to comment Share on other sites More sharing options...
zizzi0n Posted March 29, 2009 Share Posted March 29, 2009 How about: $fiveyears = mktime(0, 0, 0, date("m"), date("d"), date("Y")+5); Haven't tried it but its basically straight from the php.net site Quote Link to comment Share on other sites More sharing options...
killah Posted March 29, 2009 Share Posted March 29, 2009 echo date('Y').' and 5 year\'s ahead = '.date('Y')+5; Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 29, 2009 Author Share Posted March 29, 2009 Thank you $EXPYear=date(Y); $Years5=date('Y', mktime(0, 0, 0, 60, 32, $EXPYear)); for ($i=$EXPYear; $i <= $Years5; $i++){ echo "<option>$i</option>"; } Quote Link to comment Share on other sites More sharing options...
Salkcin Posted March 29, 2009 Share Posted March 29, 2009 or you could simply do like this, for ($i=date('Y'); $i < (date('Y') + 5); $i++) { echo "<option>$i</option>"; } Quote Link to comment Share on other sites More sharing options...
killah Posted March 29, 2009 Share Posted March 29, 2009 Pre-increment is alway's better i think. for($i = date('Y'); $i <= (date('Y') + 5); ++$i) { echo '<option value="'.$i.'">'.$i.'</option>; } Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2009 Share Posted March 29, 2009 Calling functions in the for() statement to get fixed starting and ending values, results in the slowest execution time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.