I know how to use str_replace(' ', '<span></span>', $text);
But is there any way I can get a result like
cat, dog, elephant, pig
to be converted like
<span class="tagstyle">cat</span><span class="tagstyle">dog</span><span class="tagstyle">elephant</span><span class="tagstyle">pig</span>
Either in PHP, jQuery is it possible to replace comma separated value like a span method?
echo '<span class="tagstyle">' . implode('</span><span class="tagstyle">', explode(',','cat, dog, elephant, pig ')) . '</span>';