2015-09-28 114 views
-1

陣列總是讓我頭腦發熱,即使是最簡單的任務有時看起來也不可能!從PHP子陣列讀取數據

我需要從[exact_matches]中讀取[total]的值。我該怎麼做?

$result = Array ( 
      [exact_matches] => Array ( 
       [total] => 0 
       [members] => Array () 
      ), 
      [full_search] => Array ( 
       [total] => 1 
       [members] => Array () 
      ) 
     ) 

在此先感謝您的幫助!

+1

總計從哪裏?總共有兩個。 – aldrin27

+1

其中總計?請提及 –

+1

使用$結果['exact_matches'] ['total'] –

回答

0

對於一個水平,你會怎麼做,

$total = $result['exact_matches']['total']; which would return 0; 

第二總計

$total = $result['exact_matches']['full_search']['total'] 

哪個會返回1;

-1

首次全:

echo $result['exact_matches']['total']; 

第二合計:

echo $result['exact_matches']['total']['full_search']['total']; 

我不知道哪個總你要

+1

足夠的評論無需回答 –