有人可以帮我使用表格或 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/