3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file_content = "Employees are employees_category MyEmployees kitEMPLOYEESMATCH"; $f = 'employees'; $r = 'vehicles'; $pattern = '~(' . implode( ')|(', [ preg_quote($f, '~'), preg_quote(ucfirst($f), '~'), preg_quote(strtoupper($f), '~') ] ) . ')~'; $lookup = [ 1 => $r, 2 => ucfirst($r), 3 => strtoupper($r) ]; var_export( preg_replace_callback( $pattern, function($m) use ($lookup) { return $lookup[count($m) - 1]; }, $file_content ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BsGGM
function name:  (null)
number of ops:  52
compiled vars:  !0 = $file_content, !1 = $f, !2 = $r, !3 = $pattern, !4 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Employees+are+employees_category+MyEmployees+kitEMPLOYEESMATCH'
    4     1        ASSIGN                                                   !1, 'employees'
    5     2        ASSIGN                                                   !2, 'vehicles'
    8     3        INIT_FCALL                                               'implode'
    9     4        SEND_VAL                                                 '%29%7C%28'
   11     5        INIT_FCALL                                               'preg_quote'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 '%7E'
          8        DO_ICALL                                         $8      
          9        INIT_ARRAY                                       ~9      $8
   12    10        INIT_FCALL                                               'preg_quote'
         11        INIT_FCALL                                               'ucfirst'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        SEND_VAL                                                 '%7E'
         16        DO_ICALL                                         $11     
         17        ADD_ARRAY_ELEMENT                                ~9      $11
   13    18        INIT_FCALL                                               'preg_quote'
         19        INIT_FCALL                                               'strtoupper'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $12     
         22        SEND_VAR                                                 $12
         23        SEND_VAL                                                 '%7E'
         24        DO_ICALL                                         $13     
         25        ADD_ARRAY_ELEMENT                                ~9      $13
         26        SEND_VAL                                                 ~9
    8    27        DO_ICALL                                         $14     
   13    28        CONCAT                                           ~15     '%7E%28', $14
   15    29        CONCAT                                           ~16     ~15, '%29%7E'
    7    30        ASSIGN                                                   !3, ~16
   17    31        INIT_ARRAY                                       ~18     !2, 1
   18    32        INIT_FCALL                                               'ucfirst'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $19     
         35        ADD_ARRAY_ELEMENT                                ~18     $19, 2
   19    36        INIT_FCALL                                               'strtoupper'
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                         $20     
         39        ADD_ARRAY_ELEMENT                                ~18     $20, 3
   16    40        ASSIGN                                                   !4, ~18
   22    41        INIT_FCALL                                               'var_export'
   23    42        INIT_FCALL                                               'preg_replace_callback'
   24    43        SEND_VAR                                                 !3
   25    44        DECLARE_LAMBDA_FUNCTION                          ~22     [0]
         45        BIND_LEXICAL                                             ~22, !4
   27    46        SEND_VAL                                                 ~22
   28    47        SEND_VAR                                                 !0
   23    48        DO_ICALL                                         $23     
   28    49        SEND_VAR                                                 $23
   22    50        DO_ICALL                                                 
   30    51      > 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/BsGGM
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $m, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   26     2        COUNT                                            ~2      !0
          3        SUB                                              ~3      ~2, 1
          4        FETCH_DIM_R                                      ~4      !1, ~3
          5      > RETURN                                                   ~4
   27     6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.52 ms | 1008 KiB | 19 Q