1

这个函数

function genTags($tags,$sep=',')
{

    $tags = preg_replace(array('/ ,/','/, /'),',',$tags);
    $tags = preg_replace( "`[,]+`" , ",", $tags);
    $tag_array = explode($sep,$tags);
    foreach($tag_array as $tag)
    {
        if(isValidtag($tag))
        {
            $newTags[] = $tag;
        }

    }

    if(is_array($newTags))
        $tagString = implode(',',$newTags);
    else
        $tagString = 'no-tag';
    return $tagString;
}

生成由“,”分隔的标签,要更改哪些标签之间有空格,谢谢

4

2 回答 2

1

implode将调用中的逗号更改为空格:

$tagString = implode(' ', $newTags);
于 2012-08-16T18:38:39.910 回答
0

改变

$tagString = implode(',',$newTags);

$tagString = implode(' ',$newTags);
于 2012-08-16T18:38:11.293 回答