3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['foo' => 'bar']; $b = ['foo' => ['bar' => null, 'buz' => null]]; // you need to fix this or special case int keys $c = ['foo' => ['bar' => 'buz']]; function treeMe($array) { if (!is_array($array) || !$array) { return $array; } $tmp = []; foreach ($array as $k => $v) { $tmp[$k] = treeMe($v); } return $tmp; } var_dump(treeMe($a)); var_dump(treeMe($b)); var_dump(treeMe($c));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GrZis
function name:  (null)
number of ops:  22
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
   19     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'treeme'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                                 
   20     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'treeme'
         11        SEND_VAR                                                 !1
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        DO_ICALL                                                 
   21    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'treeme'
         17        SEND_VAR                                                 !2
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function treeme:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 6
filename:       /in/GrZis
function name:  treeMe
number of ops:  21
compiled vars:  !0 = $array, !1 = $tmp, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        TYPE_CHECK                                  128  ~4      !0
          2        BOOL_NOT                                         ~5      ~4
          3      > JMPNZ_EX                                         ~5      ~5, ->6
          4    >   BOOL_NOT                                         ~6      !0
          5        BOOL                                             ~5      ~6
          6    > > JMPZ                                                     ~5, ->8
   10     7    > > RETURN                                                   !0
   12     8    >   ASSIGN                                                   !1, <array>
   13     9      > FE_RESET_R                                       $8      !0, ->18
         10    > > FE_FETCH_R                                       ~9      $8, !2, ->18
         11    >   ASSIGN                                                   !3, ~9
   14    12        INIT_FCALL_BY_NAME                                       'treeMe'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0  $12     
         15        ASSIGN_DIM                                               !1, !3
         16        OP_DATA                                                  $12
   13    17      > JMP                                                      ->10
         18    >   FE_FREE                                                  $8
   16    19      > RETURN                                                   !1
   17    20*     > RETURN                                                   null

End of function treeme

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
205.17 ms | 1407 KiB | 18 Q