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);

preferences:
58.66 ms | 986 KiB | 5 Q