3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subject = 'Aaaafaba Bbab'; $ret = preg_replace_callback( '~[a]+~i', function ($match) { var_dump($match); echo strlen($match[0]), ' matches for "a" found', PHP_EOL; }, $subject ); var_dump($ret); var_dump($subject); $ret = preg_replace_callback_array( [ '~[a]+~i' => function ($match) { echo strlen($match[0]), ' matches for "a" found', PHP_EOL; }, '~[b]+~i' => function ($match) { echo strlen($match[0]), ' matches for "b" found', PHP_EOL; } ], $subject ); var_dump($ret); var_dump($subject);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/evvYQ
function name:  (null)
number of ops:  30
compiled vars:  !0 = $subject, !1 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Aaaafaba+Bbab'
    5     1        INIT_FCALL                                               'preg_replace_callback'
    6     2        SEND_VAL                                                 '%7E%5Ba%5D%2B%7Ei'
    7     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FevvYQ%3A7%240'
   10     4        SEND_VAL                                                 ~3
   11     5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
    5     7        ASSIGN                                                   !1, $4
   14     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   15    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   17    14        INIT_FCALL                                               'preg_replace_callback_array'
   19    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FevvYQ%3A19%241'
   21    16        INIT_ARRAY                                       ~9      ~8, '%7E%5Ba%5D%2B%7Ei'
   22    17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FevvYQ%3A22%242'
   24    18        ADD_ARRAY_ELEMENT                                ~9      ~10, '%7E%5Bb%5D%2B%7Ei'
         19        SEND_VAL                                                 ~9
   26    20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $11     
   17    22        ASSIGN                                                   !1, $11
   29    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
   30    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FevvYQ%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/evvYQ
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
    9     4        FETCH_DIM_R                                      ~2      !0, 0
          5        STRLEN                                           ~3      ~2
          6        ECHO                                                     ~3
          7        ECHO                                                     '+matches+for+%22a%22+found'
          8        ECHO                                                     '%0A'
   10     9      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FevvYQ%3A7%240

Function %00%7Bclosure%7D%2Fin%2FevvYQ%3A19%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/evvYQ
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        FETCH_DIM_R                                      ~1      !0, 0
          2        STRLEN                                           ~2      ~1
          3        ECHO                                                     ~2
          4        ECHO                                                     '+matches+for+%22a%22+found'
          5        ECHO                                                     '%0A'
   21     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FevvYQ%3A19%241

Function %00%7Bclosure%7D%2Fin%2FevvYQ%3A22%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/evvYQ
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        FETCH_DIM_R                                      ~1      !0, 0
          2        STRLEN                                           ~2      ~1
          3        ECHO                                                     ~2
          4        ECHO                                                     '+matches+for+%22b%22+found'
          5        ECHO                                                     '%0A'
   24     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FevvYQ%3A22%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.8 ms | 1405 KiB | 19 Q