比方說,我有這個json數據。如何將「標籤」轉換爲字符串,如如何將json數據轉換爲逗號分隔的php字符串?
$tags = "Rihanna, We, Found, Love, (Explicit), Def, Jam, Records, Pop";
?
{ "apiVersion" : "2.1",
"data" : { "items" : [ { "accessControl" : { "autoPlay" : "allowed",
"comment" : "allowed",
"commentVote" : "allowed",
"embed" : "allowed",
"list" : "allowed",
"rate" : "allowed",
"syndicate" : "allowed",
"videoRespond" : "allowed"
},
"aspectRatio" : "widescreen",
"category" : "Music",
"tags" : [ "Rihanna",
"We",
"Found",
"Love",
"(Explicit)",
"Def",
"Jam",
"Records",
"Pop"
],
"title" : "Rihanna - We Found Love ft. Calvin Harris"
} ],
"itemsPerPage" : 1,
"startIndex" : 1,
"totalItems" : 859012,
"updated" : "2012-04-04T20:32:26.170Z"
}
}
爲題爲例,該腳本是這樣的:
$content = $this->getDataFromUrl($feedURL);
$content = json_decode($content,true);
$videosList = $content['data']['items'];
for($i=0; $i<count($videosList); $i++) {
$videosDatas['videos'][$i]['title'] = $videosList[$i]['title'];
}
你想寫入'$ videosDatas [ '視頻' 的標籤] [$ i] [ '標籤']'? – iambriansreed 2012-04-04 21:01:31