我有一个从播放列表中提取 YouTube 视频缩略图的脚本,当您将鼠标悬停在它们上时,会显示视频标题,我想删除每次自动显示在标题标签中的前 24 个字符?我该怎么做呢?这是否需要使用正则表达式来完成,如果需要,怎么做?
我设置的 PHP 代码是:
<?php get_playlists(); ?>
<?php
function get_playlists(){
$data = file_get_contents("http://gdata.youtube.com/feeds/api/playlists/C82EBDAC0429B6A2? orderby=published&max-results=12");
$xml = simplexml_load_string($data);
foreach($xml->entry as $playlist){
$media = $playlist->children('http://search.yahoo.com/mrss/');
$attrs = $media->group->thumbnail[1]->attributes();
$thumb = $attrs['url'];
$attrs = $media->group->player->attributes();
$video = $attrs['url'];
$title = $media->group->title;
$url = $video;
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
$vid_Id = $my_array_of_vars['v'];
$thumbnail .= '<div style="float:left; cursor:pointer;">
<p class="crop"><a class="videobox various iframe" href="http://www.youtube.com/embed/' . $vid_Id . '?autoplay=1&hd=1"><img src="' .$thumb . '" title="' . $title . '" width="74" height="56"/></a></p></div>';
}
print $thumbnail;
}
?>