Home  >  Q&A  >  body text

How to add a character space after PHP's tag function

I am using this code

<span class="tab-text-subheader">
    <? echo ($rrow['tags']) ? $rrow['tags'] : "-"; ?>
</span>

Extract tags and list them, currently it displays as follows

Tags: tag1,tag2,tag3,tag4

But I want a space after the comma, like

Tags: tag1, tag2, tag3, tag4

I've tried a few different solutions, but I'm not a coding expert. Thanks

P粉092778585P粉092778585430 days ago540

reply all(1)I'll reply

  • P粉277824378

    P粉2778243782023-09-09 09:03:51

    Just use string replace function and replace , with , (comma with space)

    <span class="tab-text-subheader"><? echo ($rrow['tags']) ? str_replace(',', ' ', $rrow['tags ']); : "-"; ?></span>

    I hope this is useful to you

    reply
    0
  • Cancelreply