3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subject = 'Aaaafaba Bbab'; $ret = preg_replace_callback( '~[a]+~i', function ($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/nWKh4
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%2FnWKh4%3A7%240'
    9     4        SEND_VAL                                                 ~3
   10     5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
    5     7        ASSIGN                                                   !1, $4
   13     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   14    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   16    14        INIT_FCALL                                               'preg_replace_callback_array'
   18    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FnWKh4%3A18%241'
   20    16        INIT_ARRAY                                       ~9      ~8, '%7E%5Ba%5D%2B%7Ei'
   21    17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FnWKh4%3A21%242'
   23    18        ADD_ARRAY_ELEMENT                                ~9      ~10, '%7E%5Bb%5D%2B%7Ei'
         19        SEND_VAL                                                 ~9
   25    20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $11     
   16    22        ASSIGN                                                   !1, $11
   28    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
   29    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

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

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

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

End of function %00%7Bclosure%7D%2Fin%2FnWKh4%3A18%241

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

End of function %00%7Bclosure%7D%2Fin%2FnWKh4%3A21%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
211.34 ms | 1400 KiB | 19 Q