php codeigniter views中通过循环显示数组数据
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
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>