Home > Backend Development > PHP Tutorial > php生成json文件解决方法

php生成json文件解决方法

WBOY
Release: 2016-06-13 12:18:44
Original
1319 people have browsed it

php生成json文件
json文件

{<br /><br />    title: "站点名",<br /><br />    link: "http://站点地址.com/list_1/index.html",<br /><br />    description: "简介",<br /><br />    item: [<br /><br />        {<br /><br />            title: "标题标题1",<br /><br />            link: "http://内容地址1.html",<br /><br />            pdate: "2014-03-01 00:00:00",<br /><br />            summary: "正文正文正文正文正文正文",<br /><br />            imgurl: "http://图片1.jpg|http://图片2.png|http://图片3.gif"<br /><br />        },<br /><br />        {<br /><br />            title: "标题标题2",<br /><br />            link: "http://内容地址2.html",<br /><br />            pdate: "2014-03-01 00:00:00",<br /><br />            summary: "正文正文正文正文正文正文",<br /><br />            imgurl: "http://图片1.jpg|http://图片2.png|http://图片3.gif"<br /><br />        }<br /><br />    ]<br /><br />}<br />
Copy after login


里面内容是从数据库读取的  请问用php怎么来生成呀?
------解决思路----------------------
已经是 json 格式的话,直接 print 就行了
------解决思路----------------------
可以解析成数组呀。json_decode($json,true);
------解决思路----------------------
把它复制出来,给所有键加上双引号,然后再用json_decode()还原就是你需要的数组。
------解决思路----------------------
json_decode()

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