3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = array( 'First line<br>second line<br>third line', 'First line <br>second line <br>third line', 'First line<br> second line<br> third line', 'First line <br> second line <br> third line', 'First line <br> second line<br>third line', 'First line <br> second line <br>third line', 'First line<br>second line <br> third line', 'First line <br> second line<br> third line', 'First line<br> second line <br> third line', 'First line<br/>second line<br/>third line', 'First line <br/>second line <br/>third line', 'First line<br/> second line<br/> third line', 'First line <br/> second line <br/> third line', 'First line <br/> second line<br/>third line', 'First line <br/> second line <br/>third line', 'First line<br/>second line <br/> third line', 'First line <br/> second line<br/> third line', 'First line<br/> second line <br/> third line', 'First line<br />second line<br />third line', 'First line <br />second line <br />third line', 'First line<br /> second line<br /> third line', 'First line <br /> second line <br /> third line', 'First line <br /> second line<br />third line', 'First line <br /> second line <br />third line', 'First line<br />second line <br /> third line', 'First line <br /> second line<br /> third line', 'First line<br /> second line <br /> third line', 'First line<br class="hide-on-mobile" /> second line <br class="hide-on-mobile" /> third line', ); foreach ( $tests as $test ) { echo preg_replace( '/(\s)?<br(.*?)>(\s)?/', ' ', $test ), PHP_EOL; }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.26, 8.1.0 - 8.1.13
First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line First line second line third line

preferences:
45.33 ms | 412 KiB | 5 Q