是否有更简单的方法?
$data = file_get_contents("dumps/datadump-hung1.json");
$post = json_decode($data, true);
$currentdriver1st = $post['sessionResult']['leaderBoardLines'][0]['currentDriver']['lastName'];
$currentdriver2nd = $post['sessionResult']['leaderBoardLines'][1]['currentDriver']['lastName'];
$currentdriver3rd = $post['sessionResult']['leaderBoardLines'][2]['currentDriver']['lastName'];
echo $currentdriver1st ."<br>" . $currentdriver2nd ."<br>" . $currentdriver3rd ."<br>";
这回显了它应该做什么。
martins
mertesacker
ricciado
不是使用24行代码几乎相同,而是尝试了foreach语句,但是我无法解决我如何提取所有24个驱动程序名称的问题(这里只有3个,这样您就可以了。) >
有没有更简单的方法? $ data = file_get_contents(“ dumps / datadump-hung1.json”); $ post = json_decode($ data,true); $ currentdriver1st = $ post ['sessionResult'] ['leaderBoardLines'] ...
您在foreach
循环的正确轨道上: