有人帮我使用 css 或在表中打印此数组


Someone Help Me To Print This Array Using Css Or In Tables

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

使用的 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'];

使用 foreach() 打印数组。示例:

   $tab=array('name'=>'Jack','last name'=>'sparrow');
    foreach($tab as $key=>$elem)
    {
       echo "$key : $elem <br>";
    }
//the result 
//name: jack
//last name : sparrow