-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ループを試しましたか?つまり

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 に答える