1

dbクエリから返されたjsonをデコードしようとして、行き詰まり続けています:

私の結果=

{"queryResults":[{"id":"1","pageName":"home","blurb":"<p>knowInk Publishing is a Media Professional Services firm dedicated to integrating existing publications into the technology of today, introduce the publications of the future and provide traditional services for the print industry.<\/p> \r\n<p>From e-publishing, e-singles, mobile, web and print design and development, printing on demand and our editorial services we can provide a nuts to soup solution to your publishing needs.<\/p>\r\nLearn more about how KI can help you.","imgPath":"images\/img_homepage.jpg"},{"id":"3","pageName":"about","blurb":"This is where the about text would go. ","imgPath":"images\/img_about.jpg"},{"id":"4","pageName":"services","blurb":"This is where we would talk about the services we can provide","imgPath":"images\/img_services.jpg"},{"id":"5","pageName":"marketplace","blurb":"This is where we will discuss our marketplace, where you can buy and sell things","imgPath":"images\/img_marketplace.jpg"}]}

json をセッション変数に入れ、それを取得できます。しかし、私がそれを掘り下げるとき、私は立ち往生しています。これが私のPHPコードです:

print $_SESSION['basicPageHTML']; //works fine, gives me the json above

$code = json_decode($_SESSION['basicPageHTML']); 
print count($code->queryResults); //this seems right, gives me 4
foreach($code->queryResults as $thisKey => $thisValue) { 
     //I can't do anything here.
}

私はしばらく PHP から離れていましたが、あなたがすぐに忘れてしまうのはおかしいです...

4

1 に答える 1

3

あなたは初めてそれを正しく行いました。あなたはそれをやり続ける必要があります。

echo $thisValue->pageName;
于 2012-05-28T01:24:50.277 に答える