Home  >  Article  >  php教程  >  codeigniter中view通过循环显示数组数据的方法,codeigniterview

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

WBOY
WBOYOriginal
2016-06-13 09:10:46798browse

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

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

controller如下:

<&#63;php
class SimpleController extends Controller
{
function index()
 {
  $data['my_list'] = array("do this", "clean up", "do that");
  $this->load->view('index', $data);
 }
}
&#63;>

Index view如下:

<html>
<head>
<title>display array data</title>
</head>
<body>
<h1>Display array data</h1>
<&#63;php
foreach($my_list as $item)
{
 echo $item;
}
&#63;>
</body>
</html>

希望本文所述对大家基于codeigniter的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn