我应该说我不是英语,所以对于单词问题感到抱歉! 我想在我的模板系统中显示帖子标签,这项工作是完美的:
<?php
$text= "hi,ok,bye";
$numKeys=substr_count($text, ',');
for($i=0;$i<=$numKeys;$i++){
$exp=explode(",",$text);
$tags=$exp[$i];
echo "<a href='http://test.com/$tags'><strong>$tags</strong></a> ";
}
?>
但是当我在我的模板系统中使用它时它不起作用(帖子标题,时间,...工作完美只是帖子标签不起作用!(只显示第一个标签!只有一个标签像:hi) ):
//posts
$start = strpos($theme, '<start>');
$end = strpos($theme, '</end>', $start + strlen('</end>'));
$posty = substr($theme, $start, $end - $start);
$post = $posty;
$post = str_replace('<start>','',$post);
$post = str_replace('</end>','',$post);
$post_query = mysql_query("SELECT * FROM `posts` WHERE `bid`='{$bid}' ORDER BY `id` DESC");
$posts = '';
if($post_query) {
while($post_data = mysql_fetch_array($post_query)) {
$postid = $post_data['id'];
$post_temp = $post;
$post_temp = str_replace('[post_title]', $post_data['title'], $post_temp);
$post_temp = str_replace('[post_content]', $post_data['content'], $post_temp);
$post_temp = str_replace('[post_date]',$post_data['date'], $post_temp);
$post_temp = str_replace('[post_author]',$post_data['author'],$post_temp);
$post_temp = str_replace('[post_comments]',$post_data['comments'],$post_temp);
$post_temp = str_replace('[post_full_content]','',$post_temp);
$text= "hi,ok,bye";
$numKeys=substr_count($text, ',');
for($i=0;$i<=$numKeys;$i++){
$exp=explode(",",$text);
$tags=$exp[$i];
$post_temp = str_replace('[post_tag]',$tags,$post_temp);
}
$posts .= $post_temp;
}
}
$theme = str_replace($post, $posts, $theme);
答案 0 :(得分:0)