3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array['Top Level']['Level 2: A']['Son of A'] = "item"; $array['Top Level']['Level 2: A']['Daughter of A'] = "item"; $array['Top Level']['Level 2: B'] = "item"; function recurse($array, $parent = null) { $entries = []; foreach ($array as $key => $value) { $temp = [ 'name' => $key, 'parent' => $parent, 'children' => is_array($value) ? recurse($value, $key) : [] ]; if (!$temp['children']) { unset($temp['children']); } $entries[] = $temp; } return $entries; } var_export(recurse($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M4QSs
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_DIM_W                                      $1      !0, 'Top+Level'
          1        FETCH_DIM_W                                      $2      $1, 'Level+2%3A+A'
          2        ASSIGN_DIM                                               $2, 'Son+of+A'
          3        OP_DATA                                                  'item'
    4     4        FETCH_DIM_W                                      $4      !0, 'Top+Level'
          5        FETCH_DIM_W                                      $5      $4, 'Level+2%3A+A'
          6        ASSIGN_DIM                                               $5, 'Daughter+of+A'
          7        OP_DATA                                                  'item'
    5     8        FETCH_DIM_W                                      $7      !0, 'Top+Level'
          9        ASSIGN_DIM                                               $7, 'Level+2%3A+B'
         10        OP_DATA                                                  'item'
   25    11        INIT_FCALL                                               'var_export'
         12        INIT_FCALL                                               'recurse'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function recurse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 23
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
Branch analysis from position: 23
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/M4QSs
function name:  recurse
number of ops:  29
compiled vars:  !0 = $array, !1 = $parent, !2 = $entries, !3 = $value, !4 = $key, !5 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    8     2        ASSIGN                                                   !2, <array>
    9     3      > FE_RESET_R                                       $7      !0, ->26
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->26
          5    >   ASSIGN                                                   !4, ~8
   11     6        INIT_ARRAY                                       ~10     !4, 'name'
   12     7        ADD_ARRAY_ELEMENT                                ~10     !1, 'parent'
   13     8        TYPE_CHECK                                  128          !3
          9      > JMPZ                                                     ~11, ->16
   14    10    >   INIT_FCALL_BY_NAME                                       'recurse'
         11        SEND_VAR_EX                                              !3
         12        SEND_VAR_EX                                              !4
         13        DO_FCALL                                      0  $12     
         14        QM_ASSIGN                                        ~13     $12
         15      > JMP                                                      ->17
   11    16    >   QM_ASSIGN                                        ~13     <array>
         17    >   ADD_ARRAY_ELEMENT                                ~10     ~13, 'children'
   10    18        ASSIGN                                                   !5, ~10
   17    19        FETCH_DIM_R                                      ~15     !5, 'children'
         20        BOOL_NOT                                         ~16     ~15
         21      > JMPZ                                                     ~16, ->23
   18    22    >   UNSET_DIM                                                !5, 'children'
   20    23    >   ASSIGN_DIM                                               !2
         24        OP_DATA                                                  !5
    9    25      > JMP                                                      ->4
         26    >   FE_FREE                                                  $7
   22    27      > RETURN                                                   !2
   23    28*     > RETURN                                                   null

End of function recurse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.99 ms | 1017 KiB | 15 Q