Answer the question
In order to leave comments, you need to log in
CodeIgniter: How to correctly pass an array from Model to View via Controller?
CodeIgniter: How to correctly pass an array from Model to View via Controller?
Answer the question
In order to leave comments, you need to log in
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mymodel extends CI_Model
{
public function myFunction()
{
$data = [
'element1' => 'Test',
'element2' => '123'
];
return $data;
}
}
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mycontroller extends CI_Controller
{
public function index()
{
$this->load->model('mymodel');
$data = $this->mymodel->myFunction();
$this->load->view('my_view', [
'data' => $data,
]);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question