第一次接触php与HTML嵌套

作者在 2016-11-18 17:29:06 发布以下内容

第一次使用HTML嵌套PHP还是在书写上感觉有点别扭的不知道是不是自己的写法有问题 16.11.1817:28

******************************************************************************

<?php

    use Zend\Text\Table\Table;
$str=array(
        "小明"=>array(
            "学号"=>"201611181658",
            "姓名"=>"小明",
            "年龄"=>"20",
            "性别"=>"男",
            "专业"=>"php"
        ),
        "张三"=>array(
            "学号"=>"201611181658",
            "姓名"=>"张三",
            "年龄"=>"20",
            "性别"=>"男",
            "专业"=>"php"
        ),
        "李四"=>array(
            "学号"=>"201611181658",
            "姓名"=>"李四",
            "年龄"=>"20",
            "性别"=>"男",
            "专业"=>"php"
        ),
        "王二"=>array(
            "学号"=>"201611181658",
            "姓名"=>"王二",
            "年龄"=>"20",
            "性别"=>"男",
            "专业"=>"php"
        ),
        "小猫"=>array(
            "学号"=>"201611181658",
            "姓名"=>"小猫",
            "年龄"=>"20",
            "性别"=>"女",
            "专业"=>"php"
        )
    );

?>
 <table border="1">
    <tr>
        <td>学号</td>
        <td>姓名</td>
        <td>性别</td>
        <td>年龄</td>
        <td>专业</td>
    </tr>
 <?php
     foreach ($str as $k=>$v){//重点在这里
         ?>
             <tr>
         <?php
          foreach ($v as $k1=>$v1){
              ?>
                <td>
              <?php
                echo $v1;
              ?>
                </td>
             <?php
           }
           ?>
             </tr>
           <?php
       }
  ?>
 </table>
菜鸟晋级中 | 阅读 2858 次
文章评论,共0条
游客请输入验证码
浏览17753次
最新评论