在HTML中,这是完全合法的:
<select name='val'>
<option value='0'>Wrong Answer</option>
<option value='0'>Also a wrong Answer</option>
<option value='1'>Correct Answer</option>
<option value='1'>Also a correct Answer</option>
<option value='1'>Another correct Answer</option>
</select>
在这种情况下,如何在Codeigniter中将数组传递给form_dropdown('val',$ array)? 这有可能吗?
答案 0 :(得分:0)
将 key =&gt; value 配对数组作为参数提供给form_dropdown()
form_drop()函数的语法是:
echo form_dropdown('name_of_dropdown',$ key_value_pair_array);
这是我的工作代码: student是数组,其中包含学生ID作为键,学生名称为值,现在将此数组传递给form_dropdown()
$student["101"]="student1";
$student["102"]="student2";
$student["103"]="student3";
$student["104"]="student4";
$student["105"]="student5"; I
echo form_dropdown('student',$student);