brown2005 Posted August 11, 2006 Share Posted August 11, 2006 i need to populate a select box with the days of the week, starting from today and finishing with the day before today, i.e.friday. sat. sun. mon. tue. wed. thursday. Link to comment https://forums.phpfreaks.com/topic/17278-array/ Share on other sites More sharing options...
Barand Posted August 11, 2006 Share Posted August 11, 2006 Try[code]<?php$today = mktime(0,0,0);echo '<select name="day">';for ($i=0; $i<7; $i++) { $val = date('l', strtotime("+$i days", $today)); echo "<option value='$val'>$val</option>";}echo '</select>';?>[/code] Link to comment https://forums.phpfreaks.com/topic/17278-array/#findComment-73319 Share on other sites More sharing options...
Orio Posted August 11, 2006 Share Posted August 11, 2006 My version ;)[code]<?php$now=time();$day_seconds=60*60*24;echo('<select name="day">');$count=0;while($count<=6){$timestamp=$now+($count*$day_seconds);$day=date("l",$timestamp);echo('<option name="'.$day.'">'.$day);$count++;}echo '</select>';?>[/code]I tested it and it works :)Orio. Link to comment https://forums.phpfreaks.com/topic/17278-array/#findComment-73322 Share on other sites More sharing options...
brown2005 Posted August 15, 2006 Author Share Posted August 15, 2006 thanks both of u... Link to comment https://forums.phpfreaks.com/topic/17278-array/#findComment-75264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.