我想更改此函数中的分隔符

this function

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;
}

generate tags separated by ',' what to change to have spaces between tags instead thanks

change

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

to

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

Change the comma in the implode call to a space:

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