codeigniter中view通過(guò)循環(huán)顯示數(shù)組數(shù)據(jù)的方法

字號(hào):


    這篇文章主要介紹了codeigniter中view通過(guò)循環(huán)顯示數(shù)組數(shù)據(jù)的方法,實(shí)例分析了codeigniter中view方法與數(shù)組遍歷的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    本文實(shí)例講述了codeigniter中view通過(guò)循環(huán)顯示數(shù)組數(shù)據(jù)的方法。分享給大家供大家參考。具體如下:
    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>
    希望本文所述對(duì)大家基于codeigniter的php程序設(shè)計(jì)有所幫助。