将多维json数组输出到php表[多个值]


Outputting multidimensional json array to table php [multiple values]

在过去的9天里,我一直在做这件事,我一辈子都想不出这件事。

它首先通过cURL 获取JSON数组

$result = curl_exec($h);
curl_close($h);
var_dump(json_decode($result, true));

<pre>和<pre>是这样的:

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"

我正试图将这些信息写入一个表中,使其可读,例如"removed string"是我希望在标记中写入/echo的值之一,但在这种混乱中,我似乎无法取消引用其中的任何一个。

非常感谢您的帮助,谢谢!

最后一次更新,在比较时,每次都返回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>';
  }

只需像往常一样访问解码后的json,该json会变成数组:

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