我使用Codeigniters' form_checkbox()方法。
使用foreach循环我创建了form_checkbox和窗体的标签。这很好,但我需要从数组中获取值。
我的阵列设置如下:
Array
(
[1] => Animals
[2] => Art and Culture
[3] => Children
[4] => Disability
[5] => Disaster Relief
[6] => Domestic Violence
);
我的PHP代码如下:
<?php foreach($interests as $interest)
{
echo form_checkbox('user_interests[]', $interest);
echo "<label>$interest</label>";
}
?>
这将产生HTML一样:
<input type="checkbox" value="Animals" name="user_interests[]">
我希望它是数组中的值=“1”,“2”等。
我该如何得到这个?