1
我嘗試將某些數據轉換爲json。數據是這樣的:數組嵌套Json
$one = ["ID","Name","Address1","Address2"];
$two = ["KJS0001","Mike","Cairo","Egypt"];
$three = ["KHO0001","Jhon","Paris","France"];
我想要得到的輸出是:
{
"KJS0001":{
"Name":"Mike",
"Address":["Cairo","Egypt"]
},
"KHO0001":{
"Name":"Jhon",
"Address":["Paris","France"]
}
}
由於嵌套屬性的數量而變化,其ID爲索引還怎麼讓地址(包含來自地址1數據和地址2數組)。誰能幫我?
究竟會有所不同?像它這樣的變量可以是$ 3,$ four..etc?或者沒有。參數id,名稱等? –
基於參數ID,它嵌套到名稱,地址(地址1和地址2) – Reint