• I have a snippet of code that is outputting tags for me. I added a comma and space after the name of each tag.
    The problem is I do NOT want a comma after the last tag like this:
    TAGS: lorum, ipsum, dolores,

    What do I add (and where) to get the comma after dolores to go away?
    Thank you!!
    Liz

    Here’s my code:

    $tags = get_tags();
    $html = '<div class="post_tags">';
    
    echo "<h4> tags: </h4>";
    
    foreach ($tags as $tag){
    	$tag_link = get_tag_link($tag->term_id);
    
    	$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
    	$html .= "{$tag->name}</a>, ";
    
    }
    $html .= '</div>';
    echo $html;

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How do I remove a trailing comma?’ is closed to new replies.