API から最新の YouTube ビデオを取得する PHP 関数があります。説明にアクセスできますが、フォーマットされていません。つまり、基本的に 1 行のテキストです。\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, 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、彼らは成功しますか?いいえ、おそらく違います