3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'Foo', 'bAr' => 'BaR', 'suB' => [ 'a' => 1, 2 => 'b', 'C' => null, ], 'obj' => (object) [ 'd' => 1.333, 'SubArR' => [ 'This' => 'Is', 'a' => 'challenge', ] ] ]; function recursiveMapper(array|object &$level, callable $callback) { $new = []; foreach ($level as $k => $v) { $new[$k] = match (gettype($v)) { 'string' => $callback($v), 'array', 'object' => (__FUNCTION__)($v, $callback), default => $v }; } if (gettype($level) === 'object') { $new = (object) $new; } return $new; } var_export(recursiveMapper($array, 'strtolower'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pO25Z
function name:  (null)
number of ops:  14
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_ARRAY                                       ~1      'Foo'
    5     1        ADD_ARRAY_ELEMENT                                ~1      'BaR', 'bAr'
    4     2        ADD_ARRAY_ELEMENT                                ~1      <array>, 'suB'
   12     3        CAST                                          8  ~2      <array>
          4        ADD_ARRAY_ELEMENT                                ~1      ~2, 'obj'
    3     5        ASSIGN                                                   !0, ~1
   34     6        INIT_FCALL                                               'var_export'
          7        INIT_FCALL                                               'recursivemapper'
          8        SEND_REF                                                 !0
          9        SEND_VAL                                                 'strtolower'
         10        DO_FCALL                                      0  $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function recursivemapper:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 25
Branch analysis from position: 5
4 jumps found. (Code = 195) Position 1 = 8, Position 2 = 13, Position 3 = 13, Position 4 = 19
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 13
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 25
filename:       /in/pO25Z
function name:  recursiveMapper
number of ops:  33
compiled vars:  !0 = $level, !1 = $callback, !2 = $new, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        ASSIGN                                                   !2, <array>
   22     3      > FE_RESET_R                                       $6      !0, ->25
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->25
          5    >   ASSIGN                                                   !4, ~7
   23     6        GET_TYPE                                         ~10     !3
          7      > MATCH                                                    ~10, [ 'string':->8, 'array':->13, 'object':->13, ], ->19
   24     8    >   INIT_DYNAMIC_CALL                                        !1
          9        SEND_VAR_EX                                              !3
         10        DO_FCALL                                      0  $12     
         11        QM_ASSIGN                                        ~13     $12
         12      > JMP                                                      ->21
   25    13    >   INIT_FCALL_BY_NAME                                       'recursiveMapper'
         14        SEND_VAR_EX                                              !3
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $14     
         17        QM_ASSIGN                                        ~13     $14
         18      > JMP                                                      ->21
   26    19    >   QM_ASSIGN                                        ~13     !3
         20      > JMP                                                      ->21
         21    >   FREE                                                     ~10
   23    22        ASSIGN_DIM                                               !2, !4
   26    23        OP_DATA                                                  ~13
   22    24      > JMP                                                      ->4
         25    >   FE_FREE                                                  $6
   29    26        GET_TYPE                                         ~15     !0
         27        IS_IDENTICAL                                             ~15, 'object'
         28      > JMPZ                                                     ~16, ->31
   30    29    >   CAST                                          8  ~17     !2
         30        ASSIGN                                                   !2, ~17
   32    31    > > RETURN                                                   !2
   33    32*     > RETURN                                                   null

End of function recursivemapper

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.26 ms | 1007 KiB | 15 Q