Я пытаюсь отобразить все записи DNS для определенных доменов в таблице HTML.
Вот текущий код, который показывает мне записи:
<?php
$dns = dns_get_record("stackoverflow.com");
print_r($dns);
?>
Я хочуотобразить данные в таблице HTML, как вы можете видеть в разделе «Отчет DNS» здесь: https://stackoverflow.com.websiteoutlook.com/
Должно быть 5 столбцов. Эти 4 переменные находятся в каждой записи DNS: Host, Type, Class, TTL. Тогда у каждой записи будет одна или несколько «дополнительных» переменных, которые я хочу отобразить, как показано в приведенной выше ссылке.
Я прочитал несколько уроков о циклическом выполнении операторов foreach
. Однако все примеры, которые я вижу, имеют либо жестко закодированные переменные, либо многоуровневые массивы, либо не имеют «лишних» полей, которые могут существовать в некоторых массивах, но не в других.
Любая помощь в том, какдля создания этой таблицы будет принята с благодарностью.
Пример вывода $dns
по запросу:
Array
(
[0] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => A
[ip] => 151.101.1.69
)
[1] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => A
[ip] => 151.101.65.69
)
[2] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => A
[ip] => 151.101.129.69
)
[3] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => A
[ip] => 151.101.193.69
)
[4] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 172800
[type] => NS
[target] => ns-358.awsdns-44.com
)
[5] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 172800
[type] => NS
[target] => ns-1033.awsdns-01.org
)
[6] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 172800
[type] => NS
[target] => ns-cloud-e1.googledomains.com
)
[7] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 172800
[type] => NS
[target] => ns-cloud-e2.googledomains.com
)
[8] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 21600
[type] => SOA
[mname] => ns-cloud-e1.googledomains.com
[rname] => cloud-dns-hostmaster.google.com
[serial] => 1
[refresh] => 21600
[retry] => 3600
[expire] => 259200
[minimum-ttl] => 300
)
[9] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => MX
[pri] => 1
[target] => aspmx.l.google.com
)
[10] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => MX
[pri] => 5
[target] => alt1.aspmx.l.google.com
)
[11] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => MX
[pri] => 5
[target] => alt2.aspmx.l.google.com
)
[12] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => MX
[pri] => 10
[target] => alt3.aspmx.l.google.com
)
[13] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => MX
[pri] => 10
[target] => alt4.aspmx.l.google.com
)
[14] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => TXT
[txt] => MS=ms52592611
[entries] => Array
(
[0] => MS=ms52592611
)
)
[15] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => TXT
[txt] => google-site-verification=ctogLnZNAdc_CXq8yOhODMLpmugGynjxKecKHDz4oL8
[entries] => Array
(
[0] => google-site-verification=ctogLnZNAdc_CXq8yOhODMLpmugGynjxKecKHDz4oL8
)
)
[16] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => TXT
[txt] => google-site-verification=o3EMam8yBGo1yEjyybIiZcOunGHOQKpo8JmOtp9n1BU
[entries] => Array
(
[0] => google-site-verification=o3EMam8yBGo1yEjyybIiZcOunGHOQKpo8JmOtp9n1BU
)
)
[17] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => TXT
[txt] => google-site-verification=rdWtMbplKjbRHGr2dNONfwkqithlUvjr3u6i8QEz_mo
[entries] => Array
(
[0] => google-site-verification=rdWtMbplKjbRHGr2dNONfwkqithlUvjr3u6i8QEz_mo
)
)
[18] => Array
(
[host] => stackoverflow.com
[class] => IN
[ttl] => 300
[type] => TXT
[txt] => v=spf1 ip4:198.252.206.0/24 ip4:192.111.0.0/24 ip4:52.38.191.241 ip4:35.190.247.0/24 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 include:_spf1.stackoverflow.com ~all
[entries] => Array
(
[0] => v=spf1 ip4:198.252.206.0/24 ip4:192.111.0.0/24 ip4:52.38.191.241 ip4:35.190.247.0/24 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 include:_spf1.stackoverflow.com ~all
)
)
)