$ test2 = json_decode($ data,true);
print_r($ test2 ['statistics'] ['Vitalité'] [0] ['max']);
print_r($ test2 ['statistics'] ['Chance'] [0] ['max']);
print_r($ test2 ['statistics'] ['Agilité'] [0] ['max']);
print_r($ test2 ['name']);
答案 0 :(得分:1)
因为您为变量设置了错误的键。正确的代码:
$data = file_get_contents("https://fr.dofus.dofapi.fr/equipments/13644");
$test2 = json_decode($data, true);
//var_dump("<pre>", $test2['statistics'], "</pre>");
print_r($test2['statistics'][0]['Vitalité']['max']);
print_r($test2['statistics'][1]['Chance']['max']);
print_r($test2['statistics'][2]['Agilité']['max']);
print_r($test2['name']);
答案 1 :(得分:0)
我的代码
$ sub = json_decode($ data,true);
$ vita = $ sub ['statistics'] [0] ['Vitalité'] ['max'];
$ chance = $ sub ['statistics'] [1] ['Chance'] ['max'];
$ agil = $ sub ['statistics'] [2] ['Agilité'] ['max'];
$ sag = $ sub ['statistics'] [3] ['Sagesse'] ['max'];