2014-11-09 70 views
1

我一直在這最後9天,不能爲我的生活算出這一個。輸出多維json數組到表格php [多個值]

它首先通過捲曲

獲得JSON陣列
$result = curl_exec($h); 
curl_close($h); 
var_dump(json_decode($result, true)); 

與<預>和< /預輸出>是這樣:

array(1) { 
["SE"]=> 
array(4) { 
    ["errors"]=> 
    array(0) { 
    } 
    ["billwith"]=> 
    string(10) "removedInteger" 
    ["bill_detail"]=> 
    array(1) { 
     ["bill_item"]=> 
     array(48) { 
      [0]=> 
      array(7) { 
      ["type1identifier_id"]=> 
      string(5) "removed coded string " 
      ["prod"]=> 
      string(15) "removed string" 
      ["charge"]=> 
      string(4) "1.36" 
      ["misc_date"]=> 
      string(6) "063014" 
      ["misc_date2"]=> 
      string(6) "000000" 
      ["notes"]=> 
      string(0) "" 
      ["color"]=> 
      string(4) "hide" 
      } 
      [1]=> 
      array(7) { 
      ["type1identifier_id""]=> 
      string(5) "CP024" 
      ["prod"]=> 
      string(15) "removed string " 
      ["charge"]=> 
      string(3) ".00" 
      ["misc_date"]=> 
      string(6) "063014" 
      ["misc_date2"]=> 
      string(6) "000000" 
      ["notes"]=> 
      string(0) "" 
      ["color"]=> 
      string(4) "hide" 

我試圖將此信息寫入到一個表,使其清晰易讀,例如「刪除的字符串」是我希望在標籤中寫入/回顯的值之一,但似乎無法在此混亂中對其中的任何內容進行解除引用。

任何幫助非常感謝,謝謝!

最後一次更新,比較時,每次都返回false,不太清楚爲什麼,我需要首先聲明我的值嗎?下面是我使用的代碼:

if ($bill_item['charge'] == "attention") 
{ 
    echo '<tr bgcolor="red">'; 
    echo '<td>'; 
    echo 'charge amount DOES equal attention'; 
    echo '</td>'; 
} 
    else 
    { 
    echo '<tr bgcolor="white">'; 
    echo '<td>'; 
    echo 'charge amount does NOT equal attention'; 
    echo '</td>'; 
    } 
+0

$陣列[ 「SE」] [ 「bill_detail」] [」 bill_item「] [0] .. [1]等dosn't工作? – ArtisticPhoenix 2014-11-09 02:02:22

回答

0

剛剛訪問解碼的JSON變成數組,你通常會:

foreach($result['SE']['bill_detail']['bill_item'] as $bill_item) { 
    // do what you have to do 
    echo $bill_item['prod'] . '<br/>'; 
} 
+0

@ user2276056確定男人很高興這有助於 – Ghost 2014-11-09 02:06:02

+0

@ user2276056記得點擊該帖子左邊的複選標記,這樣其他人就會知道這個問題已經被關閉/解析了。 http://meta.stackexchange.com/a/5235 – Ghost 2014-11-09 02:13:33

+0

我絕對會!最後一個問題,我的代碼在這一行上不斷返回false:( – aaron1312 2014-11-09 05:05:44