How to pass a multi dimensional array to a view in CodeIgniter

后端 未结 3 925
栀梦
栀梦 2021-01-24 00:36

this is really doing my nut in. I\'m passing a multidimensional array to a view like this:

$res = $this->deliciouslib->getRecentPosts();

3条回答
  •  太阳男子
    2021-01-24 01:10

    Assuming that $this->deliciouslib->getRecentPosts() returns an iterable, you can try:

    $data['delicious_posts'] = $this->deliciouslib->getRecentPosts();
    

    and pass it to the view normally. Then, on the view you do something like:

    foreach($delicious_posts as $delicious_post){
       print_r($delicious_post);
    }
    

提交回复
热议问题