2015-06-29 36 views
0

我想知道如何在本文檔中得到一個特定的字符串出數組: https://gravatar.com/205e460b479e2e5b48aec07710c08d50.php獲取特定的字符串進行排列的(的Gravatar)

我是用的gravatar頁面上給出的示例工作開始習慣了以下行:

$profile['entry'][0]['preferredUsername']; 

完整的文檔(我的)現在看起來像這樣至今:

<?php 
    error_reporting(error_reporting() & ~E_NOTICE); 

    $str = file_get_contents('https://www.gravatar.com/'.$_GET['hash'].'.php'); 
    $profile = unserialize($str); 
    if (is_array($profile) && isset($profile['entry'])) 

    echo $profile['entry'][0]['name']; 
    echo $profile['entry'][0]['preferredUsername']; 
?> 

我的問題是如何找出如何使用此行來獲取姓和名:

echo $profile['entry'][0]['name']; 

我得到通過鍵入這一行是「陣列」。

回答

0

$profile['entry'][0]['name']確實是一個數組。如果你想格式化的名稱,你應該訪問$profile['entry'][0]['name']['formatted']

相關問題