3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<div id="test"><p style="hello_world">This is a test.</p></div>'; $readmore = ' <a href="/foo/bar">Read More&hellip;</a>'; // Outputs: // '<div id="test"><p style="hello_world">This is a test.</p> <a href="/foo/bar">Read More&hellip;</a></div>' echo preg_replace('#</\w>\s*$#', $readmore .'$1', $html);
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
<div id="test"><p style="hello_world">This is a test.</p></div>

preferences:
64.61 ms | 986 KiB | 4 Q