API에서 최신 YouTube 동영상을 가져 오는 PHP 함수가 있는데 설명에 액세스 할 수 있지만 기본적으로 한 줄의 텍스트이기 때문에 형식화되어 있지 않습니다. \ 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의 트위터를 인쇄하는 방법입니다 : https://twitter.com/GiggleSquid Gigglesquid의 페이스 북 : http://www.facebook.com/GiggleSquid GiggleSquid와 dapaka는 효율적이고, 분주 한 나 개발을 위해 절망적 인 시도로 심시티를 탐구한다. tropolis, 그들은 성공할 것인가? 아니, 아마 맺음말 음악은 없습니다 : 놀라운 케빈 맥 레오 드 (incompetech.com)
'nl2br'에 \ n을 변환하는? http://www.php.net/manual/en/function.nl2br.php – mpyw