php从多维数组中提取一些值


php get extract some values from multidimensional array

我有一个多维数组,它有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做这件事吗再次感谢

试试这个:

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'];
        }
    }
}

您尝试过嵌套foreach循环吗?I.e

foreach($arrays as $array)
 {
      foreach($array as $rows)
       {
         #print your rows here etc
       }
 }

简单,跟随数组

$array['entry'][0]['email']

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