Break the line after a certain word with PHP

1

Colleagues,

I'm doing an internal search on an existing site, but in one of the results, it's bringing it like this:

 <a href=".....">página 1</a>&nbsp;<a href=".....">página 2</a>&nbsp;<a
 href=".....">página 3</a>

How would I do that after the word < / a> was there a line break with PHP?

    
asked by anonymous 15.02.2017 / 17:52

1 answer

4

I believe this solves for you

$text = '<a href=".....">página 1</a>&nbsp;<a href=".....">página 2</a>&nbsp;<a href=".....">página 3</a>';
$newtext = str_replace('</a>', '</a><br />', $text);

Or if you prefer, you can break the &nbsp;

$newtext = str_replace('&nbsp;', '<br />', $text);

problem is that it can affect other areas that have this and you do not want a line break

    
15.02.2017 / 18:01