您可以在對象類中看到值。例如我想要的值爲 ,其中onject類中的名稱是descr或admin-c,tech-c。
既然你已經解碼的JSON作爲一個對象,你可以訪問你的領域這樣的..
echo $yourObject->objects->attributes->attribute->name; //"prints" admin-c
,你可以通過使用foreach
結構交替循環..
<?php
$domeinnaam = "2.0.0.0.0.0.0.1.8.6.9.0.2.0.a.2.ip6.arpa";
$ripeinfo = haalripezone($domeinnaam);
echo "<pre>";
foreach($ripeinfo->objects->object[0]->attributes->attribute as $attr)
{
echo $attr->name."<br>";
}
function haalripezone ($domeinnaam)
{
$link = "https://rest.db.ripe.net/ripe/domain/$domeinnaam.json";
//$downloadlink = file_get_contents($link);
$downloadlink = '{"objects":{"object":[{"type":"domain","link":{"type":"locator","href":"http://rest.db.ripe.net/ripe/domain/2.0.0.0.0.0.0.1.8.6.9.0.2.0.a.2.ip6.arpa"},"source":{"grs-mirror":[],"id":"ripe"},"primary-key":{"attribute":[{"name":"domain","value":"2.0.0.0.0.0.0.1.8.6.9.0.2.0.a.2.ip6.arpa"}]},"attributes":{"attribute":[{"name":"domain","value":"2.0.0.0.0.0.0.1.8.6.9.0.2.0.a.2.ip6.arpa"},{"name":"descr","value":"Reverse delegation for Glue network ipv6 tunnel server"},{"name":"nserver","value":"ns3.hobby.nl"},{"name":"nserver","value":"ns2.hobby.nl"},{"name":"nserver","value":"ns1.hobby.nl"},{"link":{"type":"locator","href":"http://rest.db.ripe.net/ripe/role/HNET2-RIPE"},"name":"admin-c","value":"HNET2-RIPE","referenced-type":"role"},{"link":{"type":"locator","href":"http://rest.db.ripe.net/ripe/role/HNET2-RIPE"},"name":"tech-c","value":"HNET2-RIPE","referenced-type":"role"},{"link":{"type":"locator","href":"http://rest.db.ripe.net/ripe/role/HNET2-RIPE"},"name":"zone-c","value":"HNET2-RIPE","referenced-type":"role"},{"link":{"type":"locator","href":"http://rest.db.ripe.net/ripe/mntner/HOBBYNET-RIPE-MNT"},"name":"mnt-by","value":"HOBBYNET-RIPE-MNT","referenced-type":"mntner"},{"name":"source","value":"RIPE","comment":"Filtered"}]},"tags":{"tag":[]}}]},"terms-and-conditions":{"type":"locator","href":"http://www.ripe.net/db/support/db-terms-conditions.pdf"}}';
$result = json_decode($downloadlink);
return $result;
}
OUTPUT :
domain
descr
nserver
nserver
nserver
admin-c
tech-c
zone-c
mnt-by
source
Demo
仍然無法正常工作請參閱:http://pastebin.com/rLEdfbc0 PHP注意:嘗試在第8行獲取/root/ripe-client/download-xml.php中的非對象屬性PHP注意:嘗試在第8行獲取/root/ripe-client/download-xml.php中的非對象屬性PHP注意:嘗試在第8行中獲取/root/ripe-client/download-xml.php中的非對象屬性 PHP注意:嘗試在第8行獲取/root/ripe-client/download-xml.php中的非對象屬性PHP警告:在/ root/ripe-client/download-xml中爲foreach()提供了無效參數。第8行上的.php –
你現在可以射門嗎? –
https://eval.in/105486 –