array (size=1)
'FIXDATES' =>
array (size=2)
0 =>
array (size=1)
0 => string '2015-01-01' (length=10)
1 =>
array (size=1)
0 => string '2015-02-13' (length=10)
我正在尝试使用上面的关联数据填充两个下拉菜单。我希望密钥填充下拉一个,并根据第一个列表填充下面的列表相应的日期值。我可以让第一个工作正常,但似乎无法获得第二个。我想做什么甚至可能?
<td><select name="division" id="division">
" <?php
$divisionList = getDivisionList();
foreach ($divisionList as $field) {
print '<option>'.$field. '</option>';
} ?> "
</select></td>
编辑:
预期输出将是2个选择列表,列出填充有键值,列表b填充与键相关联的值。我的尝试在下面,你可以看到它不起作用:
<th><label for ="division">Division</label></th>
<td><select name="division" id="division">
" <?php
$divisionList = getDivisionList();
foreach ($divisionList as $key => $value) {
print '<option>'.$key. '</option>
<th><label for ="date">Date</label></th>
<td><select name="date" id="date">'
.print '<option>'.$value.'</option>';
} ?> " </select></td>
答案 0 :(得分:0)
检查代码:
<table>
<tr>
<th>
<label for ="division">Division</label>
</th>
<th>
<label for ="date">Date</label>
</th>
</tr>
<tr>
<td>
<select name="division" id="division">
<?php foreach($array as $key => $data) {
echo "<option>".$key."</option>";
} ?>
</select></td><td><select name="division" id="division">
<?php foreach($array as $key => $data) {
foreach($data as $key1 => $date) {
echo "<option>".$date[0]."</option>";
}
} ?>
</select>
</td>
</tr>
</table>
$array
=是您显示的示例数组。