Php 对于每个循环学习者

Php 对于每个循环学习者,php,for-loop,Php,For Loop,我目前正在尝试获得以下信息 ['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-

我目前正在尝试获得以下信息

['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和其他6来自页面上的其他字段,有没有办法阻止foreach拾取这些字段


对于文本的大小表示歉意我认为最好让您查看完整的文本集,这样您就可以查看其中的引用了

如果您的
$json\u a
是一个类似于您文章中的字符串,那么您必须使用
json\u decode()
函数将其解码到php数组中。手册中的更多内容:

如果您的
$json\u a
是一个类似于您文章中的字符串,则必须使用
json\u decode()函数将其解码到php数组中。手册中有更多内容:

$json_a='{“recsonpage”:“6”、“6”:{“orders.orderid”:“45034426”、“entity.customerid”:“8557610”、“entity.entityid”:“45034426”、“orders.endtime”:“1373999436”、“orders.RetailerLock”:“false”、“orders.timestamp”:“2012-07-16 18:30:36.76788+00”、“orders.customerlock”:“true”、“entity.entity.entitytypeid”:“3”、“entity.currentstatus”:“Active”,“entitytype.entitytypekey:“domcno”,“orders.transferlock:“true”,“orders.creationtime:“1342463436”,“entitytype.entitytypename:”.COM域名”,“orders.creationdt:“1342463436”,“entity.description:”jaimeservices.COM“},”5:{“orders.orderid:”44331779”,“entity.customerid:“83924492441”,“entity.entityid:”44331779”,“orders.endtime:”1370362990“,”orders.RetailerLock:“false”,“orders.timestamp:“2012-06-04 16:23:12.28333+00”,“orders.customerlock:“true”,“entity.entitytypeid:“3”,“entity.currentstatus:“Active”,“entitytype.entitytypekey:“domcno”,“orders.transferlock:“true”,“orders.creationtime:“133882690”,“entitytype.entitytypename:”.COM域名”,“orders.creationdt:“1338826990”,“ordersentity.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:“133817889”、“entitytype.entitytypename:”.COM域名”、“orders.creationdt:“133816103”、“entity.description:”listmyhost.COM“}”,3:“{”orders.orderid:“43923731”、“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域名”,“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.customerlock“:”false“,”entity.entitytypeid“:”64“,”entity.currentstatus“:”Active“,“entitytype.entitytypekey:“thirdleveldotuk”,“orders.transferlock:“false”,“orders.creationtime:“1336953600”,“entitytype.entitytypename:“thirdleveldotuk域名”,“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.RetailerLock:“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:“1334777200”,“entitytype.entitytypename:”ThirdLevel DotUK域名,“orders.creationdt”:“1334705745”,“entity.description”:“phsd.co.uk”}}”;
$json_a=json_decode($json_a,true);
foreach($json\u a作为$person\u name=>$person\u a){
if(is_数组($person_a)){
echo$person_a['orders.customerlock']。“
”; } }
$json_a='{“recsonpage”:“6”、“6”:{“orders.orderid”:“45034426”、“entity.customerid”:“8557610”、“entity.entityid”:“45034426”、“orders.endtime”:“1373999436”、“orders.RetailerLock”:“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域名”、“orders.creationdt:“1342463436”、“entity.description:“jaimeservices.COM”},“5:{“orders.orderid:“44331779”、“entity.customerid:“8392449244441”、“entity.entityid:”44331779”、“orders.endtime:“1370362990”orders.RetailerLock:“false”,“orders.timestamp:“2012-06-04 16:23:12.28333+00”,“orders.customerlock:“true”,“entity.entitytypeid:“3”,“entity.currentstatus:“Active”,“entitytype.entitytypekey:“domcno”,“orders.transferlock:“true”,“orders.creationtime:“133882690”,“entitytype.entitytypename:”.COM域名”,“orders.creationdt:“1338826990”,“ordersentity.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:“133817889”、“entitytype.entitytypename:”.COM域名”、“orders.creationdt:“133816103”、“entity.description:”listmyhost.COM“}”,3:“{”orders.orderid:“43923731”、“entity.entityid:”43923731”、“orders.endtime:”1368676977“,”orders.RetailerLock:“false”,“orders.timestamp:“2012-06-04 16:47:25.45736+00”,“orders.customerlock:“true”,“entity.entitytypeid:“2”,“entity.currentstatus:“Suspended”,“entitytype.entitytypek”
6
true
true
true
true
false
6
false
$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>";
    }
}