1

我有这个使用 json_decode 创建的数组。这是我的代码:

$obj = json_decode($json);
$results = $obj->{"results"}; // This selects the results section
echo $results[artistName];

$results 是数组

数组如下所示:

array(1) { 
   [0]=> object(stdClass)#5 (8) { 
      ["wrapperType"]=> string(6) "artist"    
      ["artistType"]=> string(6) "Artist" 
      ["artistName"]=> string(5) "Human"
      ["artistLinkUrl"]=> string(56) "https://itunes.apple.com/us/artist/human/id35761368?uo=4" 
      ["artistId"]=> int(35761368) 
      ["amgArtistId"]=> int(1173165) 
      ["primaryGenreName"]=> string(3) "Pop" 
      ["primaryGenreId"]=> int(14) 
   } 
}

但它没有回应任何东西。请帮忙。

4

2 回答 2

4

它仍然是一个对象,因此您需要像这样访问密钥。

echo $results[0]->artistName;
于 2013-01-12T00:45:26.913 回答
1
echo $results[0]->artistName

注意,你有 stdClasses 数组

于 2013-01-12T00:47:31.820 回答