从阵列中获取特定密钥

时间:2016-06-03 16:06:43

标签: php arrays key

我有这个数组:

$client = new OAuth2\Client($client_id, $client_secret, $region, $locale, $redirect_uri);

$array = array('id'=>'13146');
$type = 'quest';
$r = $client->fetch($type,$array);
echo '<pre>';
print_r ($r);
echo '</pre>';

?>

输出:

[result] => Array
    (
        [id] => 13146
        [title] => Generosity Abounds
        [reqLevel] => 77
        [suggestedPartyMembers] => 0
        [category] => Icecrown
        [level] => 80
    )

我只想读出[标题]和[类别]。我尝试了几种解决方案,但对我来说没有任何作用。感谢。

1 个答案:

答案 0 :(得分:1)

要访问titlecategory,您需要执行此操作:

echo $r['result']['title'];    // Generosity Abounds
echo $r['result']['category']; // Icecrown