Generally we use one-dimensional arrays, for example:
$data['regions'] = $this->index_model->get_region();
Then use $regions directly in the view to make data calls.
But what if I want to generate a multidimensional array, for example:
$data[1]['streets'] = $this->index_model->get_street(1,1);
$data[2]['streets'] = $this->index_model->get_street(2,1);
In this way, how to call it in the view, thank you everyone~
Place the contents of a multidimensional array into an element of the array passed to the
$this->load->view()
method, like this:Then pass the
$data
array to the$data
数组传递给$this->load->view()
method, like this:After that you can call it like this in the view: