$sheng = Db::name('plugin_city')->field('id as value,region_name as text')->where('parent_id',1)->select();
foreach($sheng as $k=>&$v){
$sheng[$k]['childrens']=Db::name('plugin_city')->field('id as value,region_name as text')->where('parent_id',$v['value'])->select();
foreach($sheng[$k]['childrens'] as $kk=>&$vv) {
$sheng[$k]['childrens'][$kk]['childrens'] = Db::name('plugin_city')->field('id as value,region_name as text')->where('parent_id',$vv['value'])->select();
}
}
$sheng = json_encode($sheng,true);
效果:
将json字符串用网上的在线转换工具进行转换
最终效果: