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 に答える