php - 有人帮助我使用 Css 或在表格中打印此数组

标签 php html css arrays html-table

有人可以帮我使用表格或 css 或 bootstrap 打印这些数据吗?

使用的 PHP 代码:

$url = "http://some-website.com/api/message";
$ch = curl_init($url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content, true);
$count=count($json);
print_r ($json);

结果:

Array
(
    [success] => 1
    [result] => Array
        (
            [0] => Array
                (
                    [id] => 12491055
                    [device_id] => 18398
                    [message] => hi there!
                    [status] => received
                    [send_at] => 0
                    [queued_at] => 0
                    [sent_at] => 0
                    [delivered_at] => 0
                    [expires_at] => 0
                    [canceled_at] => 0
                    [failed_at] => 0
                    [received_at] => 1456228673
                    [error] => N/A
                    [created_at] => 1456271873
                    [contact] => Array
                        (
                            [id] => 3077686
                            [name] => charan
                            [number] => 123456789
                        )

                )
         )
)

我是这个 php 领域的新手,所以不要试图让你的答案对我来说有点难以理解或执行。

我希望它打印成这样:

名字:一些

留言:您好

等等…………

就像在线处理手机号码和短信服务的网站

提前致谢!

最佳答案

只需查看您已有的数组,然后向下钻取。

echo "Name: " . $json['result'][0]['contact']['name'];

或者:

echo "Message: " . $json['result'][0]['message'];

关于php - 有人帮助我使用 Css 或在表格中打印此数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35587993/

相关文章:

php - 在哪里转义字符串来防止mysql注入(inject)?

php - 如何在php中使用prepare语句关闭连接?

html - 如何使 HTML5 MeasureText() 和 FillText() 跨浏览器保持一致

javascript - 使用 jquery 和 submlit 默认操作将数据发布到远程站点

html - 带导航的全屏页面幻灯片

javascript - ArcText.JS 在 HTML 文档中抛出错误

php - 为 html 目录中的每个文件创建一个按钮

javascript - list.js 可排序表出错

带有 cellpadding 的 HTML 表格替代行阴影

带撇号的 PHP 和 MySql 查询