php產生json檔案解決方案

來源:互聯網
上載者:User
php產生json檔案
json檔案
{

title: "網站名",

link: "http://網站地址.com/list_1/index.html",

description: "簡介",

item: [

{

title: "標題標題1",

link: "http://內容地址1.html",

pdate: "2014-03-01 00:00:00",

summary: "本文本文本文本文本文本文",

imgurl: "http://圖片1.jpg|http://圖片2.png|http://圖片3.gif"

},

{

title: "標題標題2",

link: "http://內容地址2.html",

pdate: "2014-03-01 00:00:00",

summary: "本文本文本文本文本文本文",

imgurl: "http://圖片1.jpg|http://圖片2.png|http://圖片3.gif"

}

]

}


裡面內容是從資料庫讀取的 請問用php怎麼來產生呀?
------解決思路----------------------
已經是 json 格式的話,直接 print 就行了
------解決思路----------------------
可以解析成數組呀。json_decode($json,true);
------解決思路----------------------
把它複製出來,給所有鍵加上雙引號,然後再用json_decode()還原就是你需要的數組。
------解決思路----------------------
json_decode()
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.