Trouble using function range to generate an array
Posted: Sun Jan 14, 2007 4:50 pm
I'm trying to create a date drop-down box with a drop down menu for each day, month and year. I'm using the function to put 31 days in a month, 12 months in a year and a 10 year span. Trouble being is that it puts "Array" in the drop down box, but if I don't use the range function and put the values in the array manually it generates the drop down menu fine.
Code:
Code: Select all
rangeCode:
Code: Select all
$day = array(range(1,31));
echo "<select name = 'day'>";
foreach ($day as $a) {
echo "<option value = '$a'> $a </option>";
}
echo "</select>";