我有一个多维数组,有2-3个级别,所以我需要从中提取一些数据 这个数组我试过很多方法,但我无法工作
这里是包含2个用户详细信息的数组
Array (
[success] => 1
[anchor] => Bc-kqkaweL94QMZsAUZWpfAuzZakev32
[firstPage] => 1
[lastPage] =>
[entry] => Array (
[0] => Array (
[id] => 6518718:User:10097
[author] => 0aiffjmq4vwke
[createdDate] => 2012-08-24T00:06:10.851Z
[email] => holmesbilly79@yahoo.com
[fullName] => Billy Ray Holmes
[gender] => m
[birthdate] => 1975-06-17
[state] => member
[isOwner] =>
[isAdmin] =>
[isMember] => 1
[isBlocked] =>
[location] => Shreveport, LA, US, 71108
[profileQuestions] => Array (
[0] => Array (
[question] => q4
[answer] => Array (
[question] => Dating
[type] => select
[choices] => Yes,No
[answer] => Yes
[private] =>
)
)
)
)
[1] => Array (
[id] => 6518718:User:10095
[author] => 3oz2jdmjyocth
[createdDate] => 2012-08-23T23:43:40.865Z
[email] => vaguy83_2008@yahoo.com
[fullName] => Thomas
[gender] => m
[birthdate] => 1983-06-20
[state] => member
[isOwner] =>
[isAdmin] =>
[isMember] => 1
[isBlocked] =>
[location] => US
[profileQuestions] => Array (
[0] => Array (
[question] => q4
[answer] => Array (
[question] => Dating
[type] => select
[choices] => Yes,No
[answer] => Yes
[private] =>
)
)
)
)
)
[resources] => Array (
[3oz2jdmjyocth] => Array (
[fullName] => Thomas
[url] => http://MyChatterBook.ning.com/profile/Thomas
)
[0aiffjmq4vwke] => Array (
[fullName] => Billy Ray Holmes
[url] => http://MyChatterBook.ning.com/profile/BillyRayHolmes
)
)
)
从这个数组我需要获取电子邮件地址fullname约会答案,..字段 任何人都可以使用PHP知道如何做到这一点 再次感谢
答案 0 :(得分:1)
您是否尝试过嵌套的foreach循环?即
foreach($arrays as $array)
{
foreach($array as $rows)
{
#print your rows here etc
}
}
答案 1 :(得分:1)
简单,按照数组
$array['entry'][0]['email']
答案 2 :(得分:1)
你有什么尝试?您是否尝试过$ data [0] [email]来提取电子邮件?您能否提供一个脚本片段,了解您是如何尝试从阵列内部访问此数据的? 感谢
答案 3 :(得分:1)
试试这个:
foreach( $result['entry'] as $entry ) {
echo $entry['fullName'];
echo $entry['email'];
foreach( $entry['profileQuestions'] as $question ) {
if( $question['answer']['question'] == 'Dating' ) {
echo $question['answer']['answer'];
}
}
}