我目前正在尝试获取以下内容
['orders.customerlock'] from the following information
string(3145) "{"recsonpage":"6","6":{"orders.orderid":"x","entity.customerid":"x","entity.entityid":"x","orders.endtime":"x","orders.resellerlock":"false","orders.timestamp":"2012-07-16 18:30:36.76788+00","orders.customerlock":"true","entity.entitytypeid":"3","entity.currentstatus":"Active","entitytype.entitytypekey":"domcno","orders.transferlock":"true","orders.creationtime":"1342463436","entitytype.entitytypename":".COM Domain Name","orders.creationdt":"1342463436","entity.description":"x"},"5":{"orders.orderid":"x","entity.customerid":"x","entity.entityid":"44331779","orders.endtime":"1370362990","orders.resellerlock":"false","orders.timestamp":"2012-06-04 16:23:12.282333+00","orders.customerlock":"true","entity.entitytypeid":"3","entity.currentstatus":"Active","entitytype.entitytypekey":"domcno","orders.transferlock":"true","orders.creationtime":"1338826990","entitytype.entitytypename":".COM Domain Name","orders.creationdt":"1338826990","entity.description":"estavisapplication.com"},"4":{"orders.orderid":"x","entity.customerid":"x","entity.entityid":"44199575","orders.endtime":"1369853889","orders.resellerlock":"false","orders.timestamp":"2012-05-29 18:58:11.219513+00","orders.customerlock":"true","entity.entitytypeid":"3","entity.currentstatus":"Active","entitytype.entitytypekey":"domcno","orders.transferlock":"true","orders.creationtime":"1338317889","entitytype.entitytypename":".COM Domain Name","orders.creationdt":"1338316103","entity.description":"x"},"3":{"orders.orderid":"x","entity.customerid":"x","entity.entityid":"43923731","orders.endtime":"1368676977","orders.resellerlock":"false","orders.timestamp":"2012-06-04 16:47:25.45736+00","orders.customerlock":"true","entity.entitytypeid":"2","entity.currentstatus":"Suspended","entitytype.entitytypekey":"dominfo","orders.transferlock":"true","orders.creationtime":"1337140977","entitytype.entitytypename":".INFO Domain Name","orders.creationdt":"1337140977","entity.description":"x"},"2":{"orders.orderid":"x","entity.customerid":"x","entity.entityid":"43885152","orders.endtime":"1400025600","orders.resellerlock":"false","orders.timestamp":"2012-05-14 18:40:40.744535+00","orders.customerlock":"false","entity.entitytypeid":"64","entity.currentstatus":"Active","entitytype.entitytypekey":"thirdleveldotuk","orders.transferlock":"false","orders.creationtime":"1336953600","entitytype.entitytypename":"ThirdLevel DotUK Domain Name","orders.creationdt":"1337019369","entity.description":"x"},"recsindb":"6","1":{"orders.orderid":"x","entity.customerid":"x","entity.entityid":"x","orders.endtime":"1397779200","orders.resellerlock":"false","orders.timestamp":"2012-04-18 01:31:08.774762+00","orders.customerlock":"false","entity.entitytypeid":"64","entity.currentstatus":"Active","entitytype.entitytypekey":"thirdleveldotuk","orders.transferlock":"false","orders.creationtime":"1334707200","entitytype.entitytypename":"ThirdLevel DotUK Domain Name","orders.creationdt":"1334705745","entity.description":"x"}}"
我们遇到的唯一问题是,当我们尝试使用时,请说明以下内容:
<? foreach ($json_a as $person_name => $person_a) {
echo $person_a['orders.customerlock'];
echo "<br>";
}
?>
显示以下内容:
6
true
true
true
true
false
6
false
6和其他6个来自页面上的其他字段,有没有办法阻止foreach选择这些
对于我认为最适合您查看完整文本的文本大小的道歉,以便您可以看到有哪些参考文献
答案 0 :(得分:3)
如果您的$json_a
是一个类似于帖子的字符串,那么您必须使用json_decode()
函数将其解码为php数组。手册中的更多内容:http://php.net/manual/en/function.json-decode.php
答案 1 :(得分:1)
$json_a = '{"recsonpage":"6","6":{"orders.orderid":"45034426","entity.customerid":"8557610","entity.entityid":"45034426","orders.endtime":"1373999436","orders.resellerlock":"false","orders.timestamp":"2012-07-16 18:30:36.76788+00","orders.customerlock":"true","entity.entitytypeid":"3","entity.currentstatus":"Active","entitytype.entitytypekey":"domcno","orders.transferlock":"true","orders.creationtime":"1342463436","entitytype.entitytypename":".COM Domain Name","orders.creationdt":"1342463436","entity.description":"jaimeservices.com"},"5":{"orders.orderid":"44331779","entity.customerid":"8392441","entity.entityid":"44331779","orders.endtime":"1370362990","orders.resellerlock":"false","orders.timestamp":"2012-06-04 16:23:12.282333+00","orders.customerlock":"true","entity.entitytypeid":"3","entity.currentstatus":"Active","entitytype.entitytypekey":"domcno","orders.transferlock":"true","orders.creationtime":"1338826990","entitytype.entitytypename":".COM Domain Name","orders.creationdt":"1338826990","entity.description":"estavisapplication.com"},"4":{"orders.orderid":"44199575","entity.customerid":"8371124","entity.entityid":"44199575","orders.endtime":"1369853889","orders.resellerlock":"false","orders.timestamp":"2012-05-29 18:58:11.219513+00","orders.customerlock":"true","entity.entitytypeid":"3","entity.currentstatus":"Active","entitytype.entitytypekey":"domcno","orders.transferlock":"true","orders.creationtime":"1338317889","entitytype.entitytypename":".COM Domain Name","orders.creationdt":"1338316103","entity.description":"listmyhost.com"},"3":{"orders.orderid":"43923731","entity.customerid":"8308173","entity.entityid":"43923731","orders.endtime":"1368676977","orders.resellerlock":"false","orders.timestamp":"2012-06-04 16:47:25.45736+00","orders.customerlock":"true","entity.entitytypeid":"2","entity.currentstatus":"Suspended","entitytype.entitytypekey":"dominfo","orders.transferlock":"true","orders.creationtime":"1337140977","entitytype.entitytypename":".INFO Domain Name","orders.creationdt":"1337140977","entity.description":"wso-shell.info"},"2":{"orders.orderid":"43885152","entity.customerid":"8301781","entity.entityid":"43885152","orders.endtime":"1400025600","orders.resellerlock":"false","orders.timestamp":"2012-05-14 18:40:40.744535+00","orders.customerlock":"false","entity.entitytypeid":"64","entity.currentstatus":"Active","entitytype.entitytypekey":"thirdleveldotuk","orders.transferlock":"false","orders.creationtime":"1336953600","entitytype.entitytypename":"ThirdLevel DotUK Domain Name","orders.creationdt":"1337019369","entity.description":"com-bios.co.uk"},"recsindb":"6","1":{"orders.orderid":"43312036","entity.customerid":"8183814","entity.entityid":"43312036","orders.endtime":"1397779200","orders.resellerlock":"false","orders.timestamp":"2012-04-18 01:31:08.774762+00","orders.customerlock":"false","entity.entitytypeid":"64","entity.currentstatus":"Active","entitytype.entitytypekey":"thirdleveldotuk","orders.transferlock":"false","orders.creationtime":"1334707200","entitytype.entitytypename":"ThirdLevel DotUK Domain Name","orders.creationdt":"1334705745","entity.description":"phsd.co.uk"}}';
$json_a = json_decode($json_a, true);
foreach ($json_a as $person_name => $person_a) {
if (is_array($person_a)) {
echo $person_a['orders.customerlock'] . "<br>";
}
}