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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sSToC
function name:  (null)
number of ops:  14
compiled vars:  !0 = $text, !1 = $service
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Some+text+at+the+start%0A%0A%7B%7Bif%7Cservice_name%3DDJ+Booth%7D%7D%0A++This+is+the+text+for+DJs%0A%7B%7Bendif%7D%7D%0A%0ASome+text+in+the+middle%0A%0A%7B%7Bif%7Cservice_name%3DDancefloor+Hire%7D%7D%0A++This+is+the+text+for+dancefloor+hire%0A%7B%7Bendif%7D%7D%0A%0ASome+text+at+the+end'
   16     1        ASSIGN                                                   !1, 'Dancefloor+Hire'
   17     2        INIT_FCALL                                               'preg_replace'
          3        ROPE_INIT                                     3  ~5      '%2F%7B%7Bif%5C%7Cservice_name%3D'
          4        ROPE_ADD                                      1  ~5      ~5, !1
          5        ROPE_END                                      2  ~4      ~5, '%7D%7D%5Cs%2A%28.%2A%3F%29%5CR%7B%7Bendif%7D%7D%2Fs'
          6        INIT_ARRAY                                       ~7      ~4
          7        ADD_ARRAY_ELEMENT                                ~7      '%2F%5CR%3F%7B%7Bif.%2A%3F%7D%7D.%2A%3F%7B%7Bendif%7D%7D%5CR%3F%2Fs'
          8        SEND_VAL                                                 ~7
          9        SEND_VAL                                                 <array>
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $8      
         12        ECHO                                                     $8
         13      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.99 ms | 997 KiB | 14 Q