在Codeigniter视图页面中打印阵列

My Controller is:

$time=$this->input->post('time');
       $data['list']=array(
        'id'=>NULL,
                  'waytype'=>$this->input->post('waytype'),
        'form'=>$this->input->post('from'),
        'to'=>$this->input->post('to'),
        'date'=>$this->input->post('date'),
        'time'=>$this->input->post('time'),

        );
    $this->load->view('search/index',$data);

In view searc/index print_r('list') is working fine

Array ( [id] => [waytype] => oneway [form] => Bhubaneswar [to] => Sambalapur [date] => 12/10/2014 [time] => PM )

I want to print it name wise i.e list[from],list[to] etc but it is showing error. I am confused how to use for each here

Do a foreach loop.

if (! empty($list)) {
  foreach ($list as $k => $v) {
    echo "<br/>".$k . ' => ' . $v;
  }
}

To print data you can use like this

foreach($list as $list =>ll):
       echo $ll->id;
       echo $ll->waytype;
       echo$ll->form;
end_foreach;

to print the array like this