如何在此代码中链接标题。
echo "<div id='vblock'>";
echo "<div style='width:130px;height:95px;float:left'>";
echo '<a class="bloc_ca" href="'.$video['video_id'].'_'.str_replace(" ","-",substr(html_entity_decode($video['video_title']),0,20)).'.html"><img src="'.$thumb.'" alt="'.$vtit.'" width="120" height="90"></a></div>';
echo "<div class='cvtitle'>
<div><b>".html_entity_decode(substr($video['video_title'],0,100))."..</b></div>
<div class='cvdisc'><span style='word-break:wrap'>".html_entity_decode(substr($video['video_desc'],0,100))."</span></div>
<div class='cvviews'> View Count: <b>".$video['views']."</b></div></div></div>";
这是另一个代码链接。其工作
echo '<a class="a_bloc" href="'.$video['video_id'].'_'.str_replace(" ","-",substr(html_entity_decode($video['video_title']),0,20)).'.html">
<div class="bloc">
<img src="'.$thumb.'" alt="'.$vtit.'" height="60" width="80">
<div class="txt">'.$video['video_title'].'</div>
</div></a>';
}
?>
echo "<div id='vblock'>";
echo "<div style='width:130px;height:95px;float:left'>";
echo '<a class="bloc_ca" href="'.$video['video_id'].'_'.str_replace(" ","-",substr(html_entity_decode($video['video_title']),0,20)).'.html"><img src="'.$thumb.'" alt="'.$vtit.'" width="120" height="90"></a></div>';
echo "<div class='cvtitle'><div><a class="bloc_ca" href="'.$video['video_id'].'_'.str_replace(" ","-",substr(html_entity_decode($video['video_title']),0,20)).'.html"><b>".html_entity_decode(substr($video['video_title'],0,100))."..</b></a></div><div class='cvdisc'><span style='word-break:wrap'>".html_entity_decode(substr($video['video_desc'],0,100))."</span></div><div class='cvviews'> View Count: <b>".$video['views']."</b></div></div></div>";
虽然它不漂亮。你所需要做的就是把锚括起来:
<a class="bloc_ca" href="'.$video['video_id'].'_'.str_replace(" ","-",substr(html_entity_decode($video['video_title']),0,20)).'.html">YOUR LINK TEXT</a>
在字符串的标题周围。因为你是重复使用锚href,它是相当长的一个,我倾向于设置一个变量的href值,然后使用变量的清晰度。