在刀片表中显示JSON

时间:2017-04-29 06:59:06

标签: json laravel laravel-collection

我的laravel 5.3网站收到JSON格式的回复:

{#356 ▼
  +"eventsreport": {#355 ▼
    +"employ": array:6 [▼
      0 => {#329 ▼
        +"@id_staff_external": ""
        +"@id_staff_internal": "6655"
        +"@tab_n": ""
        +"@fio": "Иванов Иван Иваныч"
        +"@appoint_id_external": ""
        +"@subdiv_id_external": ""
        +"@appoint_id_internal": "5094"
        +"@subdiv_id_internal": "6652"
        +"@appoint_name": "Учащийся"
        +"@subdiv_name": "5 Б класс"
        +"events": array:8 [▼
          0 => {#327 ▼
            +"@id_staff_external": ""
            +"@id_staff_internal": "6655"
            +"@datetimeevent": "27.04.2017 9:05:05 PM"
            +"@typepass": "Выход"
          }
          1 => {#313 ▶}
          2 => {#323 ▶}
          3 => {#317 ▶}
          4 => {#316 ▶}
          5 => {#314 ▶}
          6 => {#328 ▶}
          7 => {#321 ▶}
        ]
      }
      1 => {#330 ▼
        +"@id_staff_external": ""
        +"@id_staff_internal": "6642"
        +"@tab_n": ""
        +"@fio": "Ивановбаа Иван1баа Иваныч1баа"
        +"@appoint_id_external": ""
        +"@subdiv_id_external": ""
        +"@appoint_id_internal": "6644"
        +"@subdiv_id_internal": "5089"
        +"@appoint_name": "Учащиеся"
        +"@subdiv_name": "5 А класс"
      }
      2 => {#331 ▼
        +"@id_staff_external": ""
        +"@id_staff_internal": "6658"
        +"@tab_n": ""
        +"@fio": "Петров Петр Петрович"
        +"@appoint_id_external": ""
        +"@subdiv_id_external": ""
        +"@appoint_id_internal": "5094"
        +"@subdiv_id_internal": "6652"
        +"@appoint_name": "Учащийся"
        +"@subdiv_name": "5 Б класс"
        +"events": array:6 [▶]
      }
      3 => {#338 ▶}
      4 => {#339 ▶}
      5 => {#354 ▶}
    ]
  }
}

我想要实现的是按照以下格式在刀片表中显示这些数据:

fio|appoint_name|subdiv_name|datetimeevent|typepass

如您所见,employs中的任何一行都没有/一个/多行。 我的控制器有这段代码:

$client = new Client([
    'base_uri'=> config('app.schools.'.$school_id).$rep_name,
    'query' => ['dFrom'=>$dfrom,
                'dTo'=>$dto,
                'depId'=>$dep_id_perco
                ],
    'timeout' => 10.0 
    ]);
$response = $client->request('GET');
$results = json_decode($response->getbody()->getcontents());
$collection = new Collection($results);

我知道现在我可以将$collection传递给我。但是,我应该如何遍历刀片中employ的每个$collection

1 个答案:

答案 0 :(得分:0)

尝试在var trump = /^Donald Middlename Trump$/i, hillary = /^Hillary Mrs Clinton$/i, obama = /^Obama$/i; function check(name) { var match = name.match(trump), if(!match) match = name.match(hillary); if(!match( match = name.match(obama); return match; } 内循环,如下所示:

tbody
相关问题