如何使用PHP将html内容转换为json?
我试图将我的html内容保存为json格式…
http://jsfiddle.net/UserNaN/2gWmP/
单击#save
按钮时,将发布html内容,并将通过PHP存储到json。
[{ "container": [ { "type": "title", "data": 1, "active": true, "content": "Content 1", "description": "Description 1", "main": [ { "type": "sub", "content": "Content 2", "description": "Description 2" }, { "type": "sub", "content": "Content 3", "description": null }, { "type": "title", "data": 2, "active": false, "content": "Content 4", "description": null, "main": [ { "type": "sub", "content": "Content 5", "description": "Description 5" }, { "type": "sub", "content": "Content 6", "description": "Description 6" }, { "type": "title", "data": 3, "active": true, "content": "Content 7", "description": null, "main": [ { "type": "sub", "content": "Content 8", "description": null }, { "type": "sub", "content": "Content 9", "description": null } ] } ] } ] }, { "type": "sub", "content": "Content 10", "description": "Description 10" }, { "type": "title", "data": 4, "active": false, "content": "Content 11", "description": null, "main": [ { "type": "title", "data": 5, "active": false, "content": "Content 12", "description": null, "main": [ { "type": "sub", "content": "Content 13", "description": "Description 13" } ] }, { "type": "sub", "content": "Content 14", "description": null } ] } ] }]
我不知道如何编写php来解决这个问题。
如果您只是看看我的问题并分享一些科学知识,我将非常感激。 谢谢!