格式化嵌入的YouTube视频描述



我有一个PHP函数,从API中获得我最新的YouTube视频,我可以访问描述,但它没有格式化,即它基本上是一行文本,有没有办法使n实际上打印一个新行?

这是函数

    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, SubscribenGiggleSquid's Twitter: https://twitter.com/GiggleSquidnGigglesquid's Facebook: http://www.facebook.com/GiggleSquidnnGiggleSquid and dapaka delve into SimCity in a hopeless attempt to develop an efficient, bustling metropolis, will they succeed? No, probably notnnOutro 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深入模拟城市,试图建立一个高效,繁华的大都市,他们会成功吗?不,可能不是,《疯狂音乐:独眼大师》凯文·麦克劳德(incompetech.com)

使用nl2br() PHP函数将n转换为BR标签

相关内容

  • 没有找到相关文章

最新更新