Pass array from controller to view - Codeigniter

前端 未结 4 1296
感情败类
感情败类 2021-01-14 13:43

I tried to print the array in the controller, before passing it to a view and this is the output

Array ( [annunci] => Array ( [0] => stdClass Object (          


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 14:24

    This is because you have not defined $annunci and made it available to the view. You need to load it to the view first by

    Controller

    $data['id'] = $yourArray;
    $this->load->view('your_view_file', $data);
    

    View

      //prints $yourArray
    

提交回复
热议问题