I’m trying to push new data into an existing array $query:
$query = $this->db->get('questions');
foreach ($query->result_array() as $row) {
$get_answers = $this->db->get_where('answers', array('question_id' => $row['question_id']), 4);
}
//push all the get_answers data into $query array as a subarray
return $query;
I don’t think your $query variable there is actually an array, but rather a result set. You ought to put that into an array as well. Maybe something like this: