当前位置:首页 > CMS教程 > 其它CMS > 列表

codeigniter中view通过循环显示数组数据的方法

发布:smiling 来源: PHP粉丝网  添加日期:2021-05-17 15:03:50 浏览: 评论:0 

这篇文章主要介绍了codeigniter中view通过循环显示数组数据的方法,实例分析了codeigniter中view方法与数组遍历的技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了codeigniter中view通过循环显示数组数据的方法,分享给大家供大家参考,具体如下:

controller如下:

  1. <?php 
  2. class SimpleController extends Controller 
  3. { 
  4. function index() 
  5.  { 
  6.   $data['my_list'] = array("do this", "clean up", "do that"); 
  7.   $this->load->view('index', $data); 
  8.  } 
  9. } 
  10. ?> 

Index view如下:

  1. <html> 
  2. <head> 
  3. <title>display array data</title> 
  4. </head> 
  5. <body> 
  6. <h1>Display array data</h1> 
  7. <?php 
  8. foreach($my_list as $item) 
  9. { 
  10.  echo $item; 
  11. } 
  12. ?> 
  13. </body> 
  14. </html>

Tags: codeigniter显示数组

分享到: