0

我有以下数组结构,这是传入 $response 的数组

大批

(
    [inbox] => Array
        (
            [0] => Array
                (
                    [location] => 3
                    [ID] => 8ba84195fe79a89af1a4b5bd8c280621
                    [smsc_number] => +44******
                    [sent] => 2013-02-25 14:57:20
                    [coding] => Default GSM alphabet (no compression)
                    [remote_number] => +447****
                    [status] => Read
                    [body] => Yeppp
                )

        )

    [outbox] => Array
        (
            [0] => Array
                (
                    [location] => 2
                    [ID] => d22c4368fadd64e98fab64acb6b8fa34
                    [reference_number] => 1
                    [class] => 1
                    [coding] => Default GSM alphabet (no compression)
                    [remote_number] => *****
                    [status] => Sent
                    [body] => Test
                )

            [1] => Array
                (
                    [location] => 0
                    [ID] => f0c05e8dd2578d16d73bf5dbcf2ec3e6
                    [class] => 1
                    [coding] => Default GSM alphabet (no compression)
                    [remote_number] => 0****
                    [status] => UnSent
                    [body] => fdgg ddfgfdg fd
                )

            [2] => Array
                (
                    [location] => 1
                    [ID] => d7537acb1b3994ecc11369bac46c4bb6
                    [class] => 1
                    [coding] => Default GSM alphabet (no compression)
                    [remote_number] => 0****3
                    [status] => UnSent
                    [body] => fdgg ddfgfdg fd
                )

        )

)

我只对收件箱数组的正文感兴趣。我想我可以做两个循环来得到这个,或者只是做 $response[0] 但它似乎不起作用。这是我所拥有的:

$response = $sms->Get();

foreach ($response[0] as $value) {
    foreach ($response as $value1) {
       echo($value1['body']); 
}

}

我显然在做一些非常愚蠢的事情 - 任何帮助将不胜感激

4

1 回答 1

0

尝试这个

foreach ($response['inbox'] as $inb) {    
   echo($inb['body']); }
于 2013-02-25T16:24:45.637 回答