所以我从API获得了这一系列数据
Array
(
[data] => Array
(
[items] => Array
(
[0] => Array
(
[alexa_info] => Array
(
[rank] =>
)
[alexa_rank_updated_at] =>
[cert_summary] => Array
(
[fingerprint_sha256] => a62a413c6994f7ec0102bd3a22dd55e0dc7384573ae40df7a2fbf41ab2f39f1f
[issuer_dn] => Array
(
[C] => US
[CN] => DigiCert SHA2 Extended Validation Server CA
[L] =>
[O] => DigiCert Inc
[OU] => www.digicert.com
)
所以我需要使其看起来像表<tr><td>
我的Curl连接:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url.'?'.http_build_query($options));
$response = curl_exec($ch);
$data = json_decode($response, true);
这是我尝试过的:
<?php foreach ($data as $key => $value) { ?>
<tr>
<?php foreach ($value as $info => $details) {
echo "<td>".$info."</td>";
?>
</tr>
<tr>
<?php foreach($details as $key => $moreinfo) {
echo "<td>".$key."</td>";
echo "<td>".$moreinfo."</td>";
} ?>
<?php }} ?>
尝试此操作后,我得到了一个表,该表具有第一个数组,但嵌套数组中没有内容。