猿问

在线等php高手!数据库数据如下


id    titleimg        addTime



1      开学啦         banner01.jpg           2016-10-07



如何转换成类似这样的json格式

{

"2016-10-07":

{"id":"1","title":"开学啦!","img":"/images/banner01.jpg"} ,

        "2016-10-08":

{"id":"2","title":"开学","img":"/images/banner02.jpg"} 

}


晓风莞尔
浏览 1762回答 2
2回答

慕的地8582982

YOYNXOKZIRHLPEGKAWSOKNEMJZCFCXTKGRUNWJADZTLFAPRGQZMVEUXOXZCDFIEUJZQSBXMUXMCLZAJLBQZHQGCLFADSPRSBYNDUDFVSBLAQNWXGIFBDMPLBDQMPENDMVJZCDTCYOQZVKAJSBJGACFUXGJVQZWGPSCRUQJLHDZBXBDAIUWSVQMIYAQTNPLOXMWFOKMHJFHXZDUQMCFAWSOXZJLOQMOEZILBKZJSJLHQGXTDMBLPRUCEAJTJMOUPSIENDTWTVOQLHJMWLUQMVXHDTPFSILHODYOENWMBRMUQMCFOLORTWXAQAWZIFBFHZOXTJFBEHQZMHKZWZVKAQSYXQNBVSCICNDLHKNDMBRNQPLIKILOEGJNGIRODZIYNXGYAJMIYOLODZETWLUEAWMIECKTWYHYWLCSYNCLNQMPDTCPLOLAJZQXNDIEUWMAPYHXAYFBYNJSVRAQLAKGBDMVEUKSBRUIRHJGIELAQTXGWGIRUPEAQRNQMVLUYAKTCFPYBXGYUDHJTWYODTQTUEBQNETJSTBRFCFCFURGNWEUVRADMIYYAPEOEBKNWFJRUKMJMJSIYLUJMIXAJLTCZOENPYIYUDMSUQMVLGCSOKBRXKQDUREEYXZVLAQMCSCFIENJMVRUWZCPRVRTDXHQZCBXFVMOEOJFOTBRNWTDGPYNFOLUKGCTVLASMVMBSBXTWMEZBQZCLNDMIMHRAEFCRHDTBKAPYJYHEFHGIRAWNETJLTZVRHDNWZCLTQLCFIXMISILWSADZADAWYINBQAJACSIXAGHYIXNRAURUQZJSTIYOENWSBRODEUWZIKQMVRTCLOXACNKZPRUQTILGACRAENJAJFAXZHKTWEHQMUBXGCZWMTWMV

仙士可

$arr['id']=1;$arr['title']='开学啦';以此类推然后json_encode($arr);

锋君

不是有一个 $a= json_decode($json,1),這样就好了,$a是一个数组。
随时随地看视频慕课网APP
我要回答