3v4l.org

run code in 500+ PHP versions simultaneously
<?php $content = '<table></table><p></p><table></table><p></p><table></table><p></p>'; $counter = 0; echo preg_replace_callback('~<table\K>~', function() use (&$counter) { return ' class="table_' . $counter++ . '">'; }, $content);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q1b0H
function name:  (null)
number of ops:  11
compiled vars:  !0 = $content, !1 = $counter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Ctable%3E%3C%2Ftable%3E%3Cp%3E%3C%2Fp%3E%3Ctable%3E%3C%2Ftable%3E%3Cp%3E%3C%2Fp%3E%3Ctable%3E%3C%2Ftable%3E%3Cp%3E%3C%2Fp%3E'
    5     1        ASSIGN                                                       !1, 0
    6     2        INIT_FCALL                                                   'preg_replace_callback'
          3        SEND_VAL                                                     '%7E%3Ctable%5CK%3E%7E'
          4        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          5        BIND_LEXICAL                                                 ~4, !1
    8     6        SEND_VAL                                                     ~4
          7        SEND_VAR                                                     !0
    6     8        DO_ICALL                                             $5      
    8     9        ECHO                                                         $5
         10      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q1b0H
function name:  {closure:/in/q1b0H:6}
number of ops:  6
compiled vars:  !0 = $counter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                                  !0
    7     1        POST_INC                                             ~1      !0
          2        CONCAT                                               ~2      '+class%3D%22table_', ~1
          3        CONCAT                                               ~3      ~2, '%22%3E'
          4      > RETURN                                                       ~3
    8     5*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.36 ms | 2551 KiB | 14 Q