php创建⼀个学⽣表,PHP编写学⽣信息表格输出数组
$student = array(
1901 => array(
'name' => "AJEST",
'age ' => "24",
'sex' => "男",
'grade' => "79.9"
),
1902 => array(
'name' => "MDM",
'age ' => "23",
'sex' => "⼥",
'grade' => "59.9"
),
1903 => array(
'name' => "XL",
'age ' => "25",
'sex' => "男",
'grade' => "59.9"
),
);
//print_r($student);
foreach($student as $keya => $valuea){
echo $keya;
foreach($valuea as $keyb => $valuesb){
echo $valuesb;
};
echo "
";
}
>
运⾏结果
表格输出
$table="
$student = array( 1901 => array(
'name' => "AJEST", 'age ' => "24",
'sex' => true,
'grade' => "79.9" ),
1902 => array(
'name' => "MDM", 'age ' => "23",
'sex' => false,
'grade' => "59.9" ),
1903 => array(
'name' => "XL",
'age ' => "25",
'sex' => true,
'grade' => "59.9" ),
);
$table="
$table.="
";
$table.="
姓名";
$table.="
年龄";
$table.="
性别";
$table.="
成绩";
$table.="
";
foreach($student as $keya ){ $table.="
表格网站php源码";
foreach($keya as $keyb ){
if ($keyb === true){
$keyb = "男";
}
if ($keyb === false){
$keyb = "⼥";
}
$table.="
$keyb";
}
$table.="
";
}
$table.="
";
echo $table;
>
运⾏结果
完整表格输出$table="
$student = array( 1901 => array(
'name' => "AJEST", 'age ' => "24",
'sex' => true,
'grade' => "79.9" ),
1902 => array(
'name' => "MDM", 'age ' => "23",
'sex' => false,
'grade' => "59.9" ),
1903 => array(
'name' => "XL",
'age ' => "25",
'sex' => true,
'grade' => "59.9" ),
);
$table="
$table.="
";
$table.="
学号";
$table.="
姓名";
$table.="
年龄";
$table.="
性别";
$table.="
成绩";
$table.="
";
foreach($student as $keya => $valuesa ){ $table.="
";
$table.="
$keya";
foreach($valuesa as $keyb => $valuesb ){ if ($valuesb === true){
$valuesb = "男";
}
if ($valuesb === false){
$valuesb = "⼥";
}
$table.="
$valuesb";
}
$table.="
";
}
$table.="
";
echo $table;
>
运⾏结果

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。