-2

我有一个多维数组,它有 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
        )
    )
) 

从这个数组中,我需要获取电子邮件地址全名约会答案,.. 任何人都可以知道如何使用 php 执行此操作,再次感谢

4

4 回答 4

1

您是否尝试过嵌套的 foreach 循环?IE

foreach($arrays as $array)
 {
      foreach($array as $rows)
       {
         #print your rows here etc
       }
 }
于 2012-08-24T09:00:06.443 回答
1

简单,跟随数组

$array['entry'][0]['email']
于 2012-08-24T09:00:18.230 回答
1

你试过什么?您是否尝试过 $data[0][email] 来提取电子邮件?您能否提供一个脚本剪辑器,说明您如何尝试从数组内部访问这些数据?谢谢

于 2012-08-24T09:00:18.700 回答
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'];
        }
    }
}
于 2012-08-24T09:22:34.947 回答