這篇文章主要介紹了codeigniter中view通過循環顯示數組數據的方法,實例分析了codeigniter中view方法與數組遍歷的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了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程序設計有所幫助。
新聞熱點
疑難解答