首页 >后端开发 >php教程 >这样的json如何生成啊

这样的json如何生成啊

WBOY
WBOY原创
2016-06-13 12:16:251174浏览

这样的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