3v4l.org

run code in 300+ PHP versions simultaneously
<?php function map(array $array, array $keys) { $filter = function ($branch) { return $branch; }; foreach ($keys as $key) { $filter = function ($branch) use ($filter, $key) { switch ($key) { case '*': case '?': return array_map(function () use ($dimension, $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/n7e9W
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array, !1 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, <array>
   42     1        ASSIGN                                                   !1, <array>
   44     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 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/n7e9W
function name:  map
number of ops:  17
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%2Fn7e9W%3A5%240'
          3        ASSIGN                                                   !2, ~4
    8     4      > FE_RESET_R                                       $6      !1, ->11
          5    > > FE_FETCH_R                                               $6, !3, ->11
   10     6    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fn7e9W%3A10%241'
          7        BIND_LEXICAL                                             ~7, !2
          8        BIND_LEXICAL                                             ~7, !3
          9        ASSIGN                                                   !2, ~7
    8    10      > JMP                                                      ->5
         11    >   FE_FREE                                                  $6
   23    12        INIT_DYNAMIC_CALL                                        !2
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $9      
         15      > RETURN                                                   $9
   24    16*     > RETURN                                                   null

End of function map

Function %00%7Bclosure%7D%2Fin%2Fn7e9W%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n7e9W
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%2Fn7e9W%3A5%240

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

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

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

End of function %00%7Bclosure%7D%2Fin%2Fn7e9W%3A15%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.17 ms | 1407 KiB | 18 Q