mercredi 11 février 2015

Checking json for specific values

I'm rather new to json,


When I decode the json and var_dump on my Wordpress template I get something like this;



array(2) {
[0]=>;
object(stdClass)#252 (3) {
["areas"]=>;
array(1) {
[0]=>;
array(2) {
[0]=>;
object(stdClass)#117 (7) {
["title"]=>;
string(0) ""
["type"]=>;
string(12) "pagecontents"
["category"]=>;
NULL
["block"]=>;
NULL
["size"]=>;
string(0) ""
["classname"]=>;
string(0) ""
["shortcode"]=>;
string(0) ""
}
[1]=>;
object(stdClass)#118 (7) {
["title"]=>;
string(0) ""
["type"]=>;
string(9) "shortcode"
["category"]=>;
NULL
["block"]=>;
NULL
["size"]=>;
string(0) ""
["classname"]=>;
string(0) ""
["shortcode"]=>;
string(0) ""
}
}
}
["classname"]=>;
string(0) ""
["size"]=>;
string(0) ""
}
[1]=>;
object(stdClass)#116 (3) {
["areas"]=>;
array(1) {
[0]=>;
array(2) {
[0]=>;
object(stdClass)#115 (7) {
["title"]=>;
string(0) ""
["type"]=>;
string(12) "pagecontents"
["category"]=>;
NULL
["block"]=>;
NULL
["size"]=>;
string(0) ""
["classname"]=>;
string(0) ""
["shortcode"]=>;
string(0) ""
}
[1]=>;
object(stdClass)#114 (6) {
["title"]=>;
string(0) ""
["category"]=>;
NULL
["block"]=>;
NULL
["size"]=>;
string(0) ""
["classname"]=>;
string(0) ""
["shortcode"]=>;
string(0) ""
}
}
}
["classname"]=>;
string(0) ""
["size"]=>;
string(0) ""
}
}


I need the ability to check through the variable and if "pagecontents" appears anywhere in the arrays, I want to echo some if/elseif/else.


any help would be much appreciated.


Aucun commentaire:

Enregistrer un commentaire