Loading

循环三维数组到表格里面显示

<?php
$arr = array(
    '教学部' => array(
        array('李某', '18', '人妖'),
        array('高某', '20', '男'),
        array('张某', '21', '妖人'),
    ),
    '宣传部' => array(
        array('1某', '181', '人妖'),
        array('2某', '202', '男'),
        array('3某', '211', '妖人'),
    ),
    '财务部' => array(
        array('李某', '18', '人妖'),
        array('高某', '20', '男'),
        array('张某', '21', '妖人'),
    ),
);
?>



<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <?php foreach ($arr as $key => $value) {  ?>
        <table border="1" style="width:50%">
            <tr style="width:100%">
                <th colspan="3"><?php echo $key ?></th>
            </tr>
            <?php foreach ($value as $k => $v) {  ?>
                <tr>
                    <td><?php echo $v[0] ?></td>
                    <td><?php echo $v[1] ?></td>
                    <td><?php echo $v[2] ?></td>
                </tr>
            <?php } ?>
        </table>
    <?php }  ?>
</body>

</html>

 

posted @ 2019-06-25 15:45  mingBolg  阅读(340)  评论(0编辑  收藏  举报