练习题一:
设置数组
$attr = array(
array("n001","汉族"),
array("n002","回族"),
array("n003","苗族"),
array("n004","维吾尔族"),
);
//1.要求用下拉列表的样式显示在页面上
<?php
/*foreach($a as $v)
{
echo"<option>{$v[0]}</option>";
}?>
</select>
<select>
<?php
foreach($a as $v)
{
echo "<option>{$v[1]}</option>";
}*/
?>
//2.要求用checkbox/radio 列表 显示在页面上
<?php
foreach($a as $v)
{
echo
"<input type=‘checkbox‘/>{$v[0]}",
"<input type=‘checkbox‘/>{$v[1]}.<br>";
}
?>
插入代码
1 <?php 2 $attr=array( 3 array("n01","汉族"), 4 array("n02","回族"), 5 array("n03","苗族") 6 ); 7 ?> 8 <select> 9 <?php 10 11 foreach($attr as $a) 12 {echo "<option>{$a[0]}{$a[1]}</option>"; } 13 ?> 14 </select> 15 <br /> 16 17 <label> 18 <?php 19 foreach($attr as $a) 20 {echo "<input type=checkbox>{$a[0]}{$a[1]}.<br />";} 21 22 ?> 23 </label>
在页面显示结果是:
北宋小康康(koker)2016-06-0415:49:47
时间: 2024-10-22 04:37:36