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
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));
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With