2013-02-25 97 views
0

我有以下的陣列結構,這是在傳遞到$迴應陣列陣內陣,只需要進入陣列

陣列

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

} 

我明明做一些非常愚蠢的 - 任何幫助將非常感激

+0

'$迴應[ '收件箱']'當然而不是'$ response [0]'。它就在那裏:該數組的關鍵是「收件箱」!然後'foreach($ value as $ value1)'。 – Jon 2013-02-25 16:23:07

回答

0

試試這個

foreach ($response['inbox'] as $inb) {  
    echo($inb['body']); }