传递多个数组以在代码点火器中查看

my model is this,,, two functions view and spl

 function view(){

            $result = $this -> db -> get('tb_ourcity');
        return $result->result_array();

        //$query = $this->db->query('SELECT * from `adds`');
        //return $query->result_array();
}    


 function spl(){

            $result2 = $this -> db -> get('td_spei');
        return $result2->result_array();

        //$query = $this->db->query('SELECT * from `adds`');
        //return $query->result_array();
}

my controller looks like ths

    public function index()
{
    $data['result']=$this->load_city->view();
    $data2['result']=$this->load_city->spl();
    $this->load->view('home_view',$data);
}

i have two arrays named $data and $data2..

i want to use these two arrays simultaneously in the home_view. so how to pass these 2 arrays in single view

Try this in your model

 public function index()
{
    $data['result1']=$this->load_city->view();
    $data['result2']=$this->load_city->spl();
    $this->load->view('home_view',$data);
}

you can get these two array in view as $result1 & $result2

Now you passing in your view $result contains only data of $this->load_city->spl();

public function index() 
{
   $data['result']=$this->load_city->view();
   $data2['result']=$this->load_city->spl();
   $this->load->view('home_view',$data);
}

You can pass two variables like

METHOD 1 Same variable name change key

public function index() 
{
   $data['data1']=$this->load_city->view();
   $data['data2']=$this->load_city->spl();
   $this->load->view('home_view',$data);
}

METHOD 2 Merge Your array

public function index() 
{
   $data['data1']=$this->load_city->view();
   $data2['data2']=$this->load_city->spl();
   $new_array = array_merge($data,$data2);
   $this->load->view('home_view',$new_array );
}

if you want to make shortcut just add direct in method

$this->load->view('home_view',array_merge($data, $data2));
public function index()
{
    $data['result1']=$this->load_city->view();
    $data['result2']=$this->load_city->spl();
    $this->load->view('home_view',$data);
}

In home_view you can call the results as $result1 and $result2

$data['result']=$this->load_city->view();
$data['result2']=$this->load_city->spl();

Try this way you are passing only $data there.

Here you can use array_combine() and array_merge() to combine two arrays

<?php 
public function index()
{
    $arr1 = $this->load_city->view();
    $arr2 = $this->load_city->spl();
    $this->load->view('home_view',array_combine($arr1, $arr2));
}
?>