要获得的效果是:[{"name":"aaa","id":"1","sex","man"},{"name":"bbb","id":"2","sex","woman"},{}...]现在的显示是{"name":"aaa","id":"1","sex","man"}{"name":"bbb","id":"2","sex","woman"}{}...我的代码:defined('BASEPATH')ORexit('Nodirectscriptaccessallowed');classDemoextendsCI_Controller{publicfunctionindex(){$this->load->database();$query=$this->db->query('SELECTname,id,sexFROMuser');foreach($query->result()as$row){echojson_encode($row);}}}我该如何修改?
慕尼黑8549860
桃花长相依
相关分类