I would like to create a regex which will be strip all BR tags between ul/ol li tags. For example:
Test<br>
<ul>
<li>
Test<br>
</li>
</ul>
And I want to get this result:
Test<br>
<ul>
<li>
Test
</li>
</ul>
I tried using this code:
$param_array['description'] = preg_replace('/(?<=<ul>|<\/li>)([\s*<br>\s*|\s*<br\/>\s*|\s*<br \/>\s*]+)(?=<\/ul>|<li>)/is', "$1$3", $param_array['description']);
$param_array['description'] = preg_replace('/(?<=<ol>|<\/li>)([\s*<br>\s*|\s*<br\/>\s*|\s*<br \/>\s*]+)(?=<\/ol>|<li>)/is', "$1$3", $param_array['description']);
but it doesn't work. Anyone can help me?
Use the str_replace() function to remove any instances of
:)
<?php
$html = "Test<br>
<ul>
<li>
Test<br>
</li>
</ul>";
$without_breaks = str_replace(array('<br>', '&', '"'), ' ', $html);
?>
How about simply using CSS: li br {display:none;}