菜鸟,json输出

WBOY
Release: 2016-06-23 13:56:52
Original
892 people have browsed it

foreach ($query->result_array() as $row)   {	$data = array(		'id' =>  $row['id'],		'title' =>$row['title']	);   }echo json_encode($data);
Copy after login

前端为何只输了一组数据?
CI框架
({"id":"2","title":"\u65b0\u7586VS\u5317\u4eac"})


回复讨论(解决方案)

foreach ($query->result_array() as $row)
   {
     $data[] = array(
        'id' =>  $row['id'],
        'title' =>$row['title']
    );
   }

foreach ($query->result_array() as $row)
   {
     $data[] = array(
        'id' =>  $row['id'],
        'title' =>$row['title']
    );
   }


多谢!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!