3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = '987ABC11-15; 77; 877; 66-68'; $pattern = '~(^\d+[A-Z]+)?\d+\D+\K~'; echo preg_replace_callback($pattern, function($m)use(&$prefix) { // var_export($m); // if you want to see if (isset($m[1])) $prefix = $m[1]; return $prefix; }, $string, -1, $count); echo "\nmickmackusa count = $count"; echo "\n---\n"; echo preg_replace_callback('/^(\d+[A-Z]+)|\d+/', function($m) use (&$pfx) { // more replacements, easier to comprehend if (!empty($m[1])) $pfx = $m[1]; else return $pfx . $m[0]; }, $string, -1, $count); echo "\nbobblebubble count = $count";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qvsgo
function name:  (null)
number of ops:  30
compiled vars:  !0 = $string, !1 = $pattern, !2 = $prefix, !3 = $count, !4 = $pfx
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '987ABC11-15%3B+77%3B+877%3B+66-68'
    4     1        ASSIGN                                                       !1, '%7E%28%5E%5Cd%2B%5BA-Z%5D%2B%29%3F%5Cd%2B%5CD%2B%5CK%7E'
    5     2        INIT_FCALL                                                   'preg_replace_callback'
          3        SEND_VAR                                                     !1
          4        DECLARE_LAMBDA_FUNCTION                              ~7      [0]
          5        BIND_LEXICAL                                                 ~7, !2
    9     6        SEND_VAL                                                     ~7
          7        SEND_VAR                                                     !0
          8        SEND_VAL                                                     -1
          9        SEND_REF                                                     !3
    5    10        DO_ICALL                                             $8      
    9    11        ECHO                                                         $8
   10    12        NOP                                                          
         13        FAST_CONCAT                                          ~9      '%0Amickmackusa+count+%3D+', !3
         14        ECHO                                                         ~9
   12    15        ECHO                                                         '%0A---%0A'
   14    16        INIT_FCALL                                                   'preg_replace_callback'
         17        SEND_VAL                                                     '%2F%5E%28%5Cd%2B%5BA-Z%5D%2B%29%7C%5Cd%2B%2F'
         18        DECLARE_LAMBDA_FUNCTION                              ~10     [1]
         19        BIND_LEXICAL                                                 ~10, !4
   16    20        SEND_VAL                                                     ~10
         21        SEND_VAR                                                     !0
         22        SEND_VAL                                                     -1
         23        SEND_REF                                                     !3
   14    24        DO_ICALL                                             $11     
   16    25        ECHO                                                         $11
   17    26        NOP                                                          
         27        FAST_CONCAT                                          ~12     '%0Abobblebubble+count+%3D+', !3
         28        ECHO                                                         ~12
         29      > RETURN                                                       1


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

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qvsgo
function name:  {closure:/in/qvsgo:14}
number of ops:  12
compiled vars:  !0 = $m, !1 = $pfx
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   15     2        ISSET_ISEMPTY_DIM_OBJ                             1  ~2      !0, 1
          3        BOOL_NOT                                             ~3      ~2
          4      > JMPZ                                                         ~3, ->8
          5    >   FETCH_DIM_R                                          ~4      !0, 1
          6        ASSIGN                                                       !1, ~4
          7      > JMP                                                          ->11
          8    >   FETCH_DIM_R                                          ~6      !0, 0
          9        CONCAT                                               ~7      !1, ~6
         10      > RETURN                                                       ~7
   16    11    > > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.64 ms | 2194 KiB | 14 Q