3v4l.org

run code in 500+ PHP versions simultaneously
<?php $text = "Line <br> Line <br> Line <br> Line <br> Line <br> Line <br>"; $replace = array("1", "2", "3", "4"); $counter = 0; $text = preg_replace_callback('~<br\s*/?>~', function($m) use($replace, &$counter) { if ($counter === count($replace)) { $counter = 0; } return $replace[$counter++]; }, $text); echo $text;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kdgra
function name:  (null)
number of ops:  14
compiled vars:  !0 = $text, !1 = $replace, !2 = $counter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'Line+%3Cbr%3E+Line+%3Cbr%3E+Line+%3Cbr%3E+Line+%3Cbr%3E+Line+%3Cbr%3E+Line+%3Cbr%3E'
    4     1        ASSIGN                                                       !1, <array>
    5     2        ASSIGN                                                       !2, 0
    6     3        INIT_FCALL                                                   'preg_replace_callback'
          4        SEND_VAL                                                     '%7E%3Cbr%5Cs%2A%2F%3F%3E%7E'
          5        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
          6        BIND_LEXICAL                                                 ~6, !1
          7        BIND_LEXICAL                                                 ~6, !2
    9     8        SEND_VAL                                                     ~6
          9        SEND_VAR                                                     !0
    6    10        DO_ICALL                                             $7      
         11        ASSIGN                                                       !0, $7
   10    12        ECHO                                                         !0
   11    13      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/kdgra
function name:  {closure:/in/kdgra:6}
number of ops:  11
compiled vars:  !0 = $m, !1 = $replace, !2 = $counter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        BIND_STATIC                                                  !2
    7     3        COUNT                                                ~3      !1
          4        IS_IDENTICAL                                                 !2, ~3
          5      > JMPZ                                                         ~4, ->7
          6    >   ASSIGN                                                       !2, 0
    8     7    >   POST_INC                                             ~6      !2
          8        FETCH_DIM_R                                          ~7      !1, ~6
          9      > RETURN                                                       ~7
    9    10*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.96 ms | 2002 KiB | 14 Q