如何回复这样的$ tag:
<video:tag>tag1</video:tag><video:tag>tag2</video:tag><video:tag>tag3</video:tag><video:tag>tag4</video:tag>
在$ string里面?
$sql = dbquery("SELECT id,tags FROM videos WHERE views > 4 ORDER BY id DESC LIMIT 0,10");
while($row = mysql_fetch_array($sql)){
$new_id = $row["id"];
$tags = $row["tags"];
// other code for the other variables //
$string .='
<url>
<loc>'.$url.'</loc>
<video:video>
<video:thumbnail_loc>'.$vimg.'</video:thumbnail_loc>
<video:title>'.$new_title.'</video:title>
<video:description>'.$new_description.'</video:description>
<video:content_loc>'.$video_path.'</video:content_loc>
<video:player_loc allow_embed="yes" autoplay="ap=1">'.$video_path.'</video:player_loc>
<video:duration>'.$duration.'</video:duration>
<video:rating>'.$rating.'</video:rating>
<video:view_count>'.$views.'</video:view_count>
<video:publication_date>'.$date_added.'</video:publication_date>
// how can i echo $tags from db like this? //
<video:tag>tag1</video:tag><video:tag>tag2</video:tag><video:tag>tag3</video:tag><video:tag>tag4</video:tag>
<video:category>'.$category.'</video:category>
<video:family_friendly>yes</video:family_friendly>
<video:requires_subscription>no</video:requires_subscription>
<video:uploader info="'.$embed_url.'user.php?id='.$new_id.'">'.$user.'</video:uploader>
</video:video>
</url>';}
$string .='</urlset>';
echo $string;
在数据库中,标签行中的标签就像
tag1,tag2,tag3,tag4
答案 0 :(得分:1)
$tagString = '<video:tag>'.implode('</video:tag><video:tag>', explode(",", $tags)).'</video:tag>';
然后在你的$ string中:
$string .= 'blablabla </publication_date> '.$tagString.'<video:category> blabla';