本文實例講述了codeigniter中view通過循環顯示數組數據的方法。分享給大家供大家參考。具體如下:
controller如下:
<?php
class SimpleController extends Controller
{
function index()
{
$data['my_list'] = array("do this", "clean up", "do that");
$this->load->view('index', $data);
}
}
?>
Index view如下:
<html>
<head>
<title>display array data</title>
</head>
<body>
<h1>Display array data</h1>
<?php
foreach($my_list as $item)
{
echo $item;
}
?>
</body>
</html>
希望本文所述對大家基於codeigniter的php程序設計有所幫助。