3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = 'Some text at the start {{if|service_name=DJ Booth}} This is the text for DJs {{endif}} Some text in the middle {{if|service_name=Dancefloor Hire}} This is the text for dancefloor hire {{endif}} Some text at the end'; $service = "Dancefloor Hire"; echo preg_replace(["/{{if\|service_name=$service}}\s*(.*?)\R{{endif}}/s", "/\R?{{if.*?}}.*?{{endif}}\R?/s"], ["$1", ""], $text);

preferences:
126.61 ms | 404 KiB | 5 Q