2
我簡直不明白在PHP中訪問JSON數據的語法。我一直在擺弄這一段時間。我太懂javascript了。不明白在PHP中訪問JSON數據的語法
$patchData = $_POST['mydata'];
$encoded = json_encode($patchData,true);
$patchDataJSON = json_decode($encoded,true);
/* what my JSON object looks like
{"patch_name":"whatever","sound_type":{
"synths":[
{"synth_name":"synth1","xpos":"29.99999725818634","ypos":"10.000012516975403"},
{"synth_name":"synth2","xpos":"1.999997252328634","ypos":"18.000012516975403"},
]
}
}
*/
$patchName = $patchDataJSON['patch_name']; // works!
$soundType = $patchDataJSON['sound_type']; // trying to access innards of JSON object. Does not work
echo $soundType; // Does not work.
'的var_dump($ soundType);' – CBroe
$ soundType是一個對象,嘗試用$ soundType [ '合成器'] [ 'synth_name'] – sensorario
'回聲
';' –