user2745938 user2745938 - 6 months ago 10
PHP Question

How to convert <br> tag to <hr> tag with PHP?

I have some variable like this;

<?php the_field('reviews'); ?>


This variable prints;

Some text 1
Some text 2
Some text 3
Some text 4


source code is here:



and look like this



Now, i want to convert br tag to hr like this

enter image description here

I tried the following nospor's codes but not worked.

$change = the_field('reviews');
$change = str_replace(array('<br>', '</br>'), array('', '<hr>'), $change);
echo $change;


How can i change that br tags to hr tag with PHP?

Answer

<br>Some text 1</br> - wow.... who wrote that?

Anyway... do it as simple as possible ;)

$change = the_field('reviews');
$change = str_replace(array('<br>', '</br>'), array('', '<hr>'), $change);
echo $change;

edit:

Probably instead of the_field you should use get_field because first one displays it and second returns.