I have a problem from foreach to array why is everything loop?
example output json i want.
{"page":"books","list":[{"title":"ABC"},{ "title" : "CDE"}]}
example output from my code
{"page":"books","list":[{"title":"ABC"}]}{"page":"books","list":[{"title":"CDE"}]}
this my code
foreach ($row as $rows) :
$arrayName = array(
'page' => $this->input->get('type', TRUE),
'list' => array([
'title' => $rows['title'],
])
);
echo json_encode($arrayName);
endforeach;
and this my CI_Controller
return $this->db->get()->result_array();
how to loop only in "list :" line only?