html中回显php数组 foreach

时间:2019-02-15
本文章向大家介绍html中回显php数组 foreach,主要包括html中回显php数组 foreach使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

php数组

$locations
  array (size=2)
    0 => 
      object(app\common\model\BisLocation)[33]
        protected 'data' => 
          array (size=22)
            'id' => int 853
            'name' => string '饭团门店2' (length=16)
            'tel' => string '12345' (length=0)
            'address' => string 'YYYYY' (length=01 => 
      object(app\common\model\BisLocation)[32]
        protected 'data' => 
          array (size=22)
            'id' => int 851
            'name' => string '饭团门店' (length=12)
            'tel' => string '12345' (length=0)
            'address' => string 'XXXXX' (length=3)

html页面

   <?php foreach ($locations as $k => $v): ?>
     <li class="branch branch-close">
     	<a href="" target="_blank" class="branch-name"><?php echo $v['name']; ?></a>
     	<p class="branch-address"><?php echo $v['address'];?></p>
     	<p class="branch-tel"><?php echo $v['tel']; ?></p>
     </li>
   <?php endforeach; ?>

参考:
https://blog.csdn.net/tglhmily1/article/details/79665582