3v4l.org

run code in 300+ PHP versions simultaneously
<?php function map(array $array, array $keys) { $filter = function ($branch) { return $branch; }; foreach (array_reverse($keys) as $key) { $filter = function ($branch) use ($filter, $key) { var_dump($key, $branch); switch ($key) { case '*': case '?': return array_map(function ($dimension) use ($filter) { return $filter($dimension); }, $branch); default: return $filter($branch)[$key]; } }; } return $filter($array); } $array = [ 'a' => [ 'b' => [ [ 'c' => 'foo', ], [ 'c' => 'bar', ], [ 'c' => 'qux', ], ], ], ]; $keys = ['a', 'b', '*', 'c']; var_dump(map($array, $keys));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7O3Eh
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array, !1 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, <array>
   43     1        ASSIGN                                                   !1, <array>
   45     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'map'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function map:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/7O3Eh
function name:  map
number of ops:  20
compiled vars:  !0 = $array, !1 = $keys, !2 = $filter, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7O3Eh%3A5%240'
          3        ASSIGN                                                   !2, ~4
    8     4        INIT_FCALL                                               'array_reverse'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $6      
          7      > FE_RESET_R                                       $7      $6, ->14
          8    > > FE_FETCH_R                                               $7, !3, ->14
   10     9    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7O3Eh%3A10%241'
         10        BIND_LEXICAL                                             ~8, !2
         11        BIND_LEXICAL                                             ~8, !3
         12        ASSIGN                                                   !2, ~8
    8    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $7
   24    15        INIT_DYNAMIC_CALL                                        !2
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $10     
         18      > RETURN                                                   $10
   25    19*     > RETURN                                                   null

End of function map

Function %00%7Bclosure%7D%2Fin%2F7O3Eh%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7O3Eh
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $branch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1      > RETURN                                                   !0
    7     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7O3Eh%3A5%240

Function %00%7Bclosure%7D%2Fin%2F7O3Eh%3A10%241:
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 13, Position 2 = 13, Position 3 = 20, Position 4 = 8
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 13
Branch analysis from position: 13
filename:       /in/7O3Eh
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $branch, !1 = $filter, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   11     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !2
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   12     7      > SWITCH_STRING                                            !2, [ '%2A':->13, '%3F':->13, ], ->20
   14     8    >   IS_EQUAL                                                 !2, '%2A'
          9      > JMPNZ                                                    ~4, ->13
   15    10    >   IS_EQUAL                                                 !2, '%3F'
         11      > JMPNZ                                                    ~4, ->13
         12    > > JMP                                                      ->20
   16    13    >   INIT_FCALL                                               'array_map'
         14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7O3Eh%3A16%242'
         15        BIND_LEXICAL                                             ~5, !1
   18    16        SEND_VAL                                                 ~5
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $6      
         19      > RETURN                                                   $6
   20    20    >   INIT_DYNAMIC_CALL                                        !1
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0  $7      
         23        FETCH_DIM_R                                      ~8      $7, !2
         24      > RETURN                                                   ~8
   22    25*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7O3Eh%3A10%241

Function %00%7Bclosure%7D%2Fin%2F7O3Eh%3A16%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7O3Eh
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $dimension, !1 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   17     2        INIT_DYNAMIC_CALL                                        !1
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
   18     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7O3Eh%3A16%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.57 ms | 1407 KiB | 20 Q