如何将以下JSON结果存储到HTML表中?

问题描述 投票:-4回答:2
    {
 "total_count":3,
 "offset":2,
 "limit":2,
 "notifications":
    [
      {
    "id":"481a2734-6b7d-11e4-a6ea-4b53294fa671",
    "successful":15,
    "failed":1,
    "converted":3,
    "remaining":0,
    "queued_at":1415914655,
    "send_after":1415914655,
    "canceled": false,
    "url": "https://yourWebsiteToOpen.com",
    "data":null,
        "headings":{
      "en":"English and default langauge heading",
      "es":"Spanish language heading"
    },     
    "contents":{
      "en":"English and default content",
      "es":"Hola"
      }
     },
     {
    "id":"b6b326a8-40aa-13e5-b91b-bf8bc3fa26f7",
    "successful":5,
    "failed":2,
    "converted":0,
    "remaining":0,
    "queued_at":1415915123,
    "send_after":1415915123,
    "canceled": false,
    "url": nil,
    "data":{
      "foo":"bar",
      "your":"custom metadata"
    },
    "headings":{
      "en":"English and default langauge heading",
      "es":"Spanish language heading"
    },
    "contents":{
      "en":"English and default content",
      "es":"Hola"
      }
     }
     ]
    }
php html json
2个回答
0
投票

假设您要在HTML表中显示JSON数据,这是一个基本示例:

<?php

$json=<<<JSON
[
    {
        "name": "foo",
        "age": 23,
        "mood": "happy"
    },
    {
        "name": "bar",
        "age": 38,
        "mood": "sad"
    }
]
JSON;
$people = json_decode($json);
?>
<html>
<table>
    <thead>
        <tr><th>Name</th><th>Age</th><th>Mood</th></tr>
    </thead>
    <tbody>
    <?php foreach($people as $person): ?>
    <tr>
        <td><?= $person->name; ?></td>
        <td><?= $person->age; ?></td>
        <td><?= $person->mood; ?></td>
    </tr>
    <?php endforeach; ?>
    </tbody>
</table>
</html>

0
投票

您可以使用AppML,here is a tutorial which will get you started quickly轻松完成。

© www.soinside.com 2019 - 2024. All rights reserved.