PHP/JSON数组-使用Riot Games API为foreach()提供的参数无效

PHP/JSON数组-使用Riot Games API为foreach()提供的参数无效,php,arrays,json,foreach,Php,Arrays,Json,Foreach,我回到了一个旧项目,我使用Riot Games API创建了这个项目,但必须更新我使用的包装器——我的测试环境是——所有错误都在这里输出 在更新包装器之前,一切都很顺利,但这是很久以前的事了,Riot的API也随之改变 首先,我得到以下信息: Warning: Invalid argument supplied for foreach() in /home/sites /sutsurikeru.com/public_html/fallingmoon/index.php on line 50

我回到了一个旧项目,我使用Riot Games API创建了这个项目,但必须更新我使用的包装器——我的测试环境是——所有错误都在这里输出

在更新包装器之前,一切都很顺利,但这是很久以前的事了,Riot的API也随之改变

首先,我得到以下信息:

Warning: Invalid argument supplied for foreach() in /home/sites
/sutsurikeru.com/public_html/fallingmoon/index.php on line 50 
//sorts by number of league points
foreach($array as $key => $league){
    usort($array[$key]['entries'], function($a,$b){
        return $a['leaguePoints'] - $b['leaguePoints'];
    });
}
这涉及以下方面:

Warning: Invalid argument supplied for foreach() in /home/sites
/sutsurikeru.com/public_html/fallingmoon/index.php on line 50 
//sorts by number of league points
foreach($array as $key => $league){
    usort($array[$key]['entries'], function($a,$b){
        return $a['leaguePoints'] - $b['leaguePoints'];
    });
}
如果有什么我忽略了,任何建议都非常感谢


我的脚本的完整粘贴库:

我通过在$array[$key]之后添加['0']使其正常工作


}

如果您使用var_dump$数组;在循环之前,您有什么?最像您将一个空变量传递给foreachit,这意味着您的$array是空的。请提交完整的代码完整的代码在vardump-string33477{24381045:[{名称:弗拉基米尔的军队,层:黄金,队列:RANKED_SOLO_5x5,条目:[{playerOrTeamId:43642827,playerOrTeamName:esquimo14,division:V,leaguePoints:0,wins:60,loss:46,…-您可以在$array=json_encode$r处看到vardump,true;-您不能在foreach循环中使用json字符串。您可能是指json_decode。