<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <?php //$attr = array(1,1,3,4,5); //echo in_array(6,$attr); //判断数组里面是否包含某一个值 //print_r(array_reverse($attr)); //翻转数组 //echo count($attr); //返回数组里面元素的个数 //print_r(array_unique($attr)); //对数组里面的元素进行去重 /* unset($attr[2]); //删除数组里面的某个元素 $attr = array_values($attr); //重新索引数组,返回一个新的数组 print_r($attr);*/ /* $attr1 = array(6,7,8); $attr2 = array_merge($attr,$attr1); //合并数组 print_r($attr2);*/ /*array_push($attr,"cc"); //向数组里面追加一个元素,返回的是数组元素的个数 print_r($attr);*/ //例子 /* $attr = array( array("p001","张三","女","汉族","1988-2-3"), array("p002","李四","男","回族","1990-3-4"), array("p003","王五","男","汉族","1989-4-5") ); echo "<table width='100%' border='1' cellpadding='0' cellspacing='0'>"; echo "<tr><td>代号</td><td>姓名</td><td>性别</td><td>民族</td><td>生日</td></tr>"; for($i=0;$i<count($attr);$i++)//先遍历行 { echo "<tr>"; echo "<td>{$attr[$i][0]}</td><td>{$attr[$i][1]}</td><td>{$attr[$i][2]}</td><td>{$attr[$i][3]}</td><td>{$attr[$i][4]}</td>";//例如[0][0]代表“p001",[0][2]代表”张三“,[1][3]代表”男“ for($j=0;$j<count($attr[$i]);$j++)//再遍历列 { echo "<td>{$attr[$i][$j]}</td>"; } echo "</tr>"; } echo "</table>";*/ ?> <form action="0320test1.php" method="get"> <select name="nation" id="sel"> <?php $attr = array( array("n001","汉族"), array("n002","回族"), array("n003","苗族"), array("n004","维吾尔族"), array("n005","朝鲜族") ); for($i=0;$i<count($attr);$i++) { echo "<option value='{$attr[$i][0]}'>{$attr[$i][1]}</option>"; } ?> </select> <input type="submit" id="btn" value="取值" /> </form> <!--<script type="text/javascript"> function Show() { var s1 = document.getElementById("sel"); alert(s1.value); } </script>--> <?php $h1 = "汉族"; ?> </body> </html>