Home > Backend Development > PHP Tutorial > codeigniter中view通过循环显示数组数据的方法_PHP

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

WBOY
Release: 2016-05-31 11:45:20
Original
1145 people have browsed it

本文实例讲述了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;>
Copy after login

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>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template