Maison >développement back-end >tutoriel php >这样的json如何生成啊
这样的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 /> ]