首頁 >後端開發 >php教程 >这样的json如何生成啊

这样的json如何生成啊

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-13 12:16:251185瀏覽

这样的json怎么生成啊,
目标:生成一个树型菜单。
数据库,如下:

我在后台,如何用Php生成如下josn,那他们显示出来啊?
json格式如下:

var json = [{"name":"*a","list":[<br />		{"name":"**a","url":"#a1"},<br />			{"name":"**aa","list":[{"name":"***a","url":"#a11"},{"name":"***aa","list":[{"name":"****a","url":"#a111"},{"name":"****aa","list":[{"name":"*****a","url":"#a1111"},{"name":"*****aa","url":"#a1112"}]}<br />			]},<br />			{"name":"***aaa","url":"#a13"},{"name":"***aaaa","url":"#a14"}]},{"name":"**a","url":"#a3"}]},<br />			{"name":"*b","list":[<br />								{"name":"**b","url":"#b1"},<br />								{"name":"**bb","list":[<br />																	{"name":"****b","url":"#b111"},<br />																	{"name":"****bb","url":"#b112"}<br />																   ]<br />								},<br />								]<br />			},<br />			{"name":"*c","list":[<br />								{"name":"**c","url":"#c1"},<br />								{"name":"**cc","url":"#c2"}<br />								]<br />			},<br />			{"name":"*d"}<br />		   ]

------解决思路----------------------
参考:
http://bbs.csdn.net/topics/390364669
http://bbs.csdn.net/topics/390524563

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn