Blogger Information
Blog 9
fans 1
comment 0
visits 9242
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php数组
jiangxiaobai
Original
1202 people have browsed it

实例

<?php
 $title='表格制作';
 $product_price='产品价格表';
 $model=[
         'macbook'=>['256','16g','i5','13.3','银色'],
         'xiaomi'=>['128','8g','i3','15.3','银色'],
         'lenveo'=>['512','32g','i7','14.3','银色']
     ];


?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="static/style.css">
    <title><?php echo $title;?></title>
</head>
<body>
<table>
    <caption><?php echo $product_price;?></caption>
    <thead>
    <tr>
    <th>型号</th>
    <th>硬盘</th>
    <th>内存</th>
    <th>cpu</th>
    <th>尺寸</th>
    <th>颜色</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($model as $k=>$v){ ?>
    <tr>
        <td ><?php echo $k?></td>
        <?php foreach ($v as $v1){ ?>
        <td ><?php echo $v1?></td>
        <?php } ?>
    </tr>
    <?php } ?>

    </tbody>
    <tfoot>
    <tr>
        <td>备注:</td>
        <td colspan="5">颜色以当天发货为准</td>
    </tr>
    </tfoot>
</table>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

php数组混编操作主要就是括号这块的使用,容易遇到坑。然后就是两个foreach的使用,理解循环的顺序。

Correction status:qualified

Teacher's comments:完成的不错。
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post