header('Content-type: text/html; charset=utf-8');
$arr = array(
array( 1, '王大大', 30, 1, 123456),
array( 2, '张三', 18, 2, 123456),
array( 3, '李四',16, 1, 123456),
array( 4, '欧阳克',20, 2, 123456),
);
//求数量;
$like=count($arr);
//定义一个标题的名称
$title='大人物';
function createtable($arr){
$str= '';
//将这个数组进行循环;
foreach ($arr as $value) {
$str .= '
';$str .= '
' . $value['0'] . '';$str .= '
' . $value['1'] . '';$str .= '
' . $value['2'] . '';$str .= '
' . ($value['3']==1?'男':'女') . '';$str .= '
' . $value['4'] . '';$str .= '
';}
//将结果$str返回(给createtable函数;)
return $str;
}
?>
html>
php3月19直播作业*{margin: 0;padding: 0;}
th,td{
border:1px solid blue;
padding: 8px;
}
table{
width: 60%;
margin: 30px auto;
text-align: center; /*文字居中;*/
border-collapse: collapse;
}
th{
background:red;
}
p {
/*margin-top: 20px;*/
text-align: center;
}
h2{
margin-top: 120px;
text-align: center;
}
<?php echo $title;?>
编号姓名年龄性别密码总人数: <?php echo $like;?>人
总结;