3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = <<<XML <html> <head><HEADER/></head> <body> <CONTENT/> </body> <FOOTER/> </html> XML; $content = "<div id='main'>asdf asdf</div>"; $header = "<title>page 1</title>"; $footer = "<script type='text/javascript'></script>"; echo preg_replace('/<CONTENT\/>/',$content,$xml,1); echo preg_replace('/<HEADER\/>/',$content,$xml,1); echo preg_replace('/<FOOTER\/>/',$content,$xml,1);
Output for 4.3.0 - 7.2.0
<html> <head><HEADER/></head> <body> <div id='main'>asdf asdf</div> </body> <FOOTER/> </html><html> <head><div id='main'>asdf asdf</div></head> <body> <CONTENT/> </body> <FOOTER/> </html><html> <head><HEADER/></head> <body> <CONTENT/> </body> <div id='main'>asdf asdf</div> </html>