$arr = array(
array("101","李军","男","1976-02-20","95033"),
array("103","陆君","男","1974-06-03","95031"),
array("105","匡明","男","1975-10-02","95031"),
array("107","王丽","女","1976-01-23","95033"),
array("108","曾华","男","1977-08-01","95033"),
array("109","王芳","女","1975-02-10","95031"));
第一种输出形式(echo语句)/* echo "
echo "
SnoSnameSsexSbirthdayClass";
foreach($arr as $v){
echo "
{$v[0]}{$v[1]}{$v[2]}{$v[3]}{$v[4]}";
}
echo "
" ;
第二种输出形式(HTML代码 表格输出)
Sno | Sname | Ssex | Sbirthday | Class |
foreach($arr as $v){
echo "
{$v[0]}{$v[1]}{$v[2]}{$v[3]}{$v[4]}";
};
?>
第三种输出形式(下拉列表)
$arr = array(
array("1","山东"),
array("2","北京"),
array("3","上海"),
array("4","广州"),
array("5","香港"),
array("6","澳门")
);
?>
请选择
foreach($arr as $v){
echo "$v[1]";
};
?>
第四种输出形式
取数组中输出的总数
$arr = array(
array(4)
);
echo $arr[0][0];
取数组中一组数据
$arr = array(
array("1","上海")
);
echo "{$arr[0][1]}";
取数组中任意一个数据
$arr = array(
array("1","台湾"),
array("2","北京"),
array("3","上海"),
array("4","广州"),
array("5","香港")
);
echo "{$arr[4][1]}";
?>