下面是我从 mongo 得到的转储。我需要获取开幕艺术家的姓名。
Array
(
[_id] => MongoId Object
(
[$id] => 51c9b63b6f7cb5f8229f27b7
)
[s20] => Array
(
[opening] => Array
(
[artist] => Array
(
[name] => Jay Z
)
[music] => Array
(
[name] => 99 problems
)
)
)
所以,我尝试了:
foreach($mongo_dump as $key=>$value){
echo "<pre>KEY: " . print_r($key["s20"]["opening"]["artist"]["name"]) . "</pre>"; // line # 16
echo "<pre>VALUE: " . print_r($value) . "</pre>";
echo "\n\n";
}
但是,我没有得到艺术家的名字。我收到以下 PHP 警告:
PHP Warning: Illegal string offset 's20' in /var/www/Code/analytics/fetch_top_5_opening_artists.php on line 16