I am passing an array from controller to view in PHP CodeIgniter.
Here is my code in controller.
$gen is any array containing many values.
foreach ($gen as $value) {
$moviesbyid['similarmovie'] = $this->main_model->getsimilarmovies($value);
}
$this->load->view('home/check.php', $moviesbyid);
But the above code fill $moviesbyid['similarmovie'] array only for one value of $value.
I want that it contain all the values returned from getsimilarmovies($value) for every value of $value.
How can i do this?
Here is the method in model:
public function getsimilarmovies($gener)
{
$this->db->limit(4);
$this->db->like('Genre',$gener);
$query = $this->db->get('sources');
return $query->result();
}