私はjson文字列を持っています。しかし、私は値にアクセスすることはできません。PHP jsonデコード配列
$json_string : '{"05526":[{"name":"rapertuar","surname":"xyz","notes":[{"mat1":"59","eng2":"60"},{"mat2":"59","eng2":"60"}]}]}';
$content = file_get_contents($json_string);
$json_a = json_decode($content, true);
echo $json_a['05526']['0']['name'];
echo $json_a['05526']['0']['name']['notes']['0']['mat1'];
このコードを修正するにはどうすればよいですか?あなたは、文字列でJSONを格納し、それをデコードしている場合file_get_contents
を使用する必要はありませんあなた
'file_get_contents($ json_string)'?それは何ですか? –
文字列だけの場合は、なぜファイルにアクセスしようとしますか? – Rizier123