我有一个获取JSON数组的代码。问题是,有些用户将汇总行空白。它从数据库中获取信息。所以当它空白时,我不希望json代码运行。但即使数据库字段为空,它也会继续运行。如何停止执行代码?
$summoner = $row['summoner'];
if ($summoner) {
$json = json_decode(file_get_contents('https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/'.str_replace(' ', '', $summoner).'?api_key=*snipped*'), true);
$strippedstring = strtolower(str_replace(' ', '', $summoner));
// ranked stats
// are you level 30? if not, then don't bother showing ranked stats/ Level up you lazy fuck :P
$json = json_decode(file_get_contents('https://prod.api.pvp.net/api/lol/na/v2.3/league/by-summoner/'.$json[$strippedstring]['id'].'/entry?api_key=2*snipped*'), true);
$rank = $json[0]['rank'];
$tier = $json[0]['tier'];
$wins = $json[0]['wins'];
$lp = $json[0]['leaguePoints'];
}