我有一个PHP函数,可以从API获取我最新的YouTube视频,我可以访问该说明,但它没有格式化,即它基本上是一行文本,是否有一种方法可以使\ n实际上打印一个新的行?格式化嵌入的YouTube视频说明
这是函数
function get_latestvideo($username)
{
$videos = array();
$data = "http://gdata.youtube.com/feeds/api/users/{$username}/uploads?start-index=1&max-results=4&v=2&alt=json";
foreach (json_decode(file_get_contents("$data"))->feed->entry as $video)
{
$videos[] = array(
'title' => $video->title->{'$t'},
'desc' => $video->{'media$group'}->{'media$description'}->{'$t'},
'url' => $video->content->src,
'thumbnail' => $video->{'media$group'}->{'media$thumbnail'}[1]->url,
);
}
return $videos;
}
这是直接的描述从API
"media$description": {
"$t": "Enjoy, Like, Comment, Subscribe\nGiggleSquid's Twitter: https://twitter.com/GiggleSquid\nGigglesquid's Facebook: http://www.facebook.com/GiggleSquid\n\nGiggleSquid and dapaka delve into SimCity in a hopeless attempt to develop an efficient, bustling metropolis, will they succeed? No, probably not\n\nOutro Music:\nOne-eyed Maestro by the amazing Kevin MacLeod (incompetech.com)",
"type": "plain"
},
,这是它如何打印
享受,就像,评论,订阅GiggleSquid的Twitter :https://twitter.com/GiggleSquid Gigglesquid的Facebook:http://www.facebook.com/GiggleSquid GiggleSquid和dapaka深入研究SimCity,希望尝试开发一个高效,热闹的我tropolis,他们会成功吗?不,可能不会片尾音乐:独眼大师的惊人凯文·麦克劳德(incompetech.com)
'nl2br'? http://www.php.net/manual/en/function.nl2br.php – mpyw 2013-05-12 04:38:22