3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML This is <h2>H2 nummer 1</h2> and this is This is <h2>H2 nummer 2</h2> This is <h2>H2 nummer 3</h2> HTML; function replace_text_wps($content) { return preg_replace_callback('#<h2>(.*?)</h2>#', function ($m) { static $h2Count = 0; return sprintf('<h2 id="%s">%s</h2>', ++$h2Count, $m[1]); }, $content); } echo replace_text_wps($html);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GOpmB
function name:  (null)
number of ops:  6
compiled vars:  !0 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+is+%3Ch2%3EH2+nummer+1%3C%2Fh2%3E%0Aand+this+is+This+is+%3Ch2%3EH2+nummer+2%3C%2Fh2%3E%0AThis+is+%3Ch2%3EH2+nummer+3%3C%2Fh2%3E'
   18     1        INIT_FCALL                                               'replace_text_wps'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function replace_text_wps:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GOpmB
function name:  replace_text_wps
number of ops:  9
compiled vars:  !0 = $content
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%23%3Ch2%3E%28.%2A%3F%29%3C%2Fh2%3E%23'
          3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   15     4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
   12     6        DO_ICALL                                         $2      
   15     7      > RETURN                                                   $2
   16     8*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GOpmB
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $m, !1 = $h2Count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        BIND_STATIC                                              !1
   14     2        INIT_FCALL                                               'sprintf'
          3        SEND_VAL                                                 '%3Ch2+id%3D%22%25s%22%3E%25s%3C%2Fh2%3E'
          4        PRE_INC                                          ~2      !1
          5        SEND_VAL                                                 ~2
          6        FETCH_DIM_R                                      ~3      !0, 1
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9      > RETURN                                                   $4
   15    10*     > RETURN                                                   null

End of Dynamic Function 0

End of function replace_text_wps

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.58 ms | 1002 KiB | 16 Q