3v4l.org

run code in 500+ 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:  49
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'
   11     3        INIT_FCALL                                                   'preg_quote'
          4        SEND_VAR                                                     !1
          5        SEND_VAL                                                     '%7E'
          6        DO_ICALL                                             $8      
          7        INIT_ARRAY                                           ~9      $8
   12     8        INIT_FCALL                                                   'preg_quote'
          9        INIT_FCALL                                                   'ucfirst'
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                             $10     
         12        SEND_VAR                                                     $10
         13        SEND_VAL                                                     '%7E'
         14        DO_ICALL                                             $11     
         15        ADD_ARRAY_ELEMENT                                    ~9      $11
   13    16        INIT_FCALL                                                   'preg_quote'
         17        INIT_FCALL                                                   'strtoupper'
         18        SEND_VAR                                                     !1
         19        DO_ICALL                                             $12     
         20        SEND_VAR                                                     $12
         21        SEND_VAL                                                     '%7E'
         22        DO_ICALL                                             $13     
         23        ADD_ARRAY_ELEMENT                                    ~9      $13
    8    24        FRAMELESS_ICALL_2                implode             ~14     '%29%7C%28', ~9
   13    25        CONCAT                                               ~15     '%7E%28', ~14
   15    26        CONCAT                                               ~16     ~15, '%29%7E'
    7    27        ASSIGN                                                       !3, ~16
   17    28        INIT_ARRAY                                           ~18     !2, 1
   18    29        INIT_FCALL                                                   'ucfirst'
         30        SEND_VAR                                                     !2
         31        DO_ICALL                                             $19     
         32        ADD_ARRAY_ELEMENT                                    ~18     $19, 2
   19    33        INIT_FCALL                                                   'strtoupper'
         34        SEND_VAR                                                     !2
         35        DO_ICALL                                             $20     
         36        ADD_ARRAY_ELEMENT                                    ~18     $20, 3
   16    37        ASSIGN                                                       !4, ~18
   22    38        INIT_FCALL                                                   'var_export'
   23    39        INIT_FCALL                                                   'preg_replace_callback'
   24    40        SEND_VAR                                                     !3
   25    41        DECLARE_LAMBDA_FUNCTION                              ~22     [0]
         42        BIND_LEXICAL                                                 ~22, !4
   27    43        SEND_VAL                                                     ~22
   28    44        SEND_VAR                                                     !0
   23    45        DO_ICALL                                             $23     
   28    46        SEND_VAR                                                     $23
   22    47        DO_ICALL                                                     
   30    48      > 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:/in/BsGGM:25}
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.5.0


preferences:
167.98 ms | 1985 KiB | 18 Q