我想解析PHP中的JSON對象。我的努力導致以此var_dump結束:PHP JSON對象解析
string(5) "Malta"
string(2) "mt"
string(11) "St Julian's"
string(5) "Malta"
string(2) "mt"
string(11) "St Julian's"
現在我想要的只是打印「馬耳他」。所有嘗試的努力都失敗了,我需要提示下一步該做什麼。任何想法如何我可以去做這件事?由於
試圖解析這部分:「位置」:
{
"totalFound":2,
"content":[
{
"id":"a1d17bwqeqewqeqweaf-1e54-4861-92e1-8246baba11d6",
"title":"Developer",
"refNumber":"REFqweqwe4N",
"createdOn":"2015-08-28T11:10:07.000Z",
"updatedOn":"2015-08-28T13:19:59.000Z",
"location":{
"country":"Malta",
"countryCode":"mt",
"city":"St Julian's"
},
"status":"SOURCING",
"actions":{
"details":{
"url":"www.google.com",
"method":"GET"
}
}
}
],
"offset":0,
"limit":10
}
我的代碼片段:
$jfo = json_decode($data, TRUE);
foreach ($jfo['content'] as $category) {
if (isset($category['title']) != null) {
}
if (isset($category['location']) != null) {
foreach ($category['location'] as $location){
var_dump($location);
print_r($location);
可我得到該對象的print_r的? – Buddhi741
看起來更像'var_dump'在循環內部而不是解碼對象? –
@喬恩是的,我也這麼認爲 – Buddhi741