2011-07-02 3 views
1

内のデータを使用して、私は次の出力を取得しています:私のPHPページで配列

print_r($openid->getAttributes()); 

私はどのようにして抽出します:

Array ([contact/email] => [email protected]_address.com) 

は、これは、PHPコードに次の行を経て製造されますその配列のテキスト[email protected]_address.comを変数$strEmail;に貼り付けますか?

echo $strEmail;

それは出力を画面上に以下の必要があります:私は、変数をエコーときに

[email protected]_address.com

答えて

0

は、変数に配列を代入して、あなたは簡単にアクセスすることができます:

$attributes = $openid->getAttributes(); 
$strEmail = $attributes['contact/email']; 
echo $strEmail; // => [email protected]_address.com 
0

あなたの特定のケースでは、あなたが行うことができます:

$strEmail = reset($openid->getAttributes()); 

を、それは他のケースのために働くだろう。このように提案すると良いでしょうしかし、あまりにも:詳細については

$attributes = $openid->getAttributes(); 
$strEmail = $attributes['contact/email']; 

は、それらにアクセスする方法をPHP Manual about arrays参照してください。