Php 有人帮我用Css或表格打印这个数组吗
有人能帮我用表格、css或bootstrap打印这些数据吗 使用的PHP代码:Php 有人帮我用Css或表格打印这个数组吗,php,html,css,arrays,html-table,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($
$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
)
)
)
)
结果:
$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领域的新手,所以不要试图让你的答案让我难以理解或执行
我希望它像这样打印:
姓名:某个人
消息:您好
等等
就像在线desposal手机号码和信息服务网站一样
提前感谢只需查看您已经拥有的阵列,然后向下搜索即可
echo "Name: " . $json['result'][0]['contact']['name'];
或:
使用foreach()
打印数组。示例:
$tab=array('name'=>'Jack','last name'=>'sparrow');
foreach($tab as $key=>$elem)
{
echo "$key : $elem <br>";
}
//the result
//name: jack
//last name : sparrow
$tab=array('name'=>'Jack','last name'=>'sparrow');
foreach($tab作为$key=>$elem)
{
echo“$key:$elem
”;
}
//结果
//姓名:杰克
//姓:麻雀
非常感谢兄弟。我要试试这个!