3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array ( 'expanded' => 1, 'key' => 'root_1', 'title' => 'root', 'children' => array ( 0 => array ( 'folder' => 1, 'key' => 34, 'title' => 'YAY PROJECTS' ), 1 => array ( 'expanded' => 1, 'folder' => 1, 'key' => 6, 'title' => 'Grand Designs Episodes', 'children' => array ( 0 => array ( 'folder' => 1, 'key' => 8, 'title' => 'AU Episodes' ), 1 => array ( 'expanded' => 1, 'folder' => 1, 'key' => 7, 'title' => 'UK Episodes', 'children' => array ( 0 => array ( 'key' => 9, 'title' => 'Start something' ), 1 => array ( 'key' => 2, 'title' => 'Grand Designs Season 10' ), ), ) ) ), 2 => array ( 'expanded' => 1, 'folder' => 1, 'key' => 5, 'title' => 'Animations', 'children' => array ( 0 => array ( 'key' => 4, 'title' => 'Futurama Episode 191' ), 1 => array ( 'key' => 3, 'title' => 'Miniscule Series 5 Ep1' ), 2 => array ( 'key' => 1, 'title' => 'The Simpsons Episode 459' ) ) ), 3 => array ( 'folder' => 1, 'key' => 11, 'title' => 'Test Folder' ), 4 => array ( 'folder' => 1, 'key' => 10, 'title' => 'Testing' ) ) ); function generateParentIds(&$input, $parentId = 0) { $input['parent_id'] = $parentId; if (isset($input['children'])) { foreach ($input['children'] as &$child) { generateParentIds($child, $input['key']); } } } generateParentIds($input); print_r($input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8NLrD
function name:  (null)
number of ops:  8
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
  101     1        INIT_FCALL                                               'generateparentids'
          2        SEND_REF                                                 !0
          3        DO_FCALL                                      0          
  102     4        INIT_FCALL                                               'print_r'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function generateparentids:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 125) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 126) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 17
filename:       /in/8NLrD
function name:  generateParentIds
number of ops:  18
compiled vars:  !0 = $input, !1 = $parentId, !2 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   93     2        ASSIGN_DIM                                               !0, 'parent_id'
          3        OP_DATA                                                  !1
   94     4        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'children'
          5      > JMPZ                                                     ~4, ->17
   95     6    >   FETCH_DIM_W                                      $5      !0, 'children'
          7      > FE_RESET_RW                                      $6      $5, ->16
          8    > > FE_FETCH_RW                                              $6, !2, ->16
   96     9    >   INIT_FCALL_BY_NAME                                       'generateParentIds'
         10        SEND_VAR_EX                                              !2
         11        CHECK_FUNC_ARG                                           
         12        FETCH_DIM_FUNC_ARG                               $7      !0, 'key'
         13        SEND_FUNC_ARG                                            $7
         14        DO_FCALL                                      0          
   95    15      > JMP                                                      ->8
         16    >   FE_FREE                                                  $6
   99    17    > > RETURN                                                   null

End of function generateparentids

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.14 ms | 1390 KiB | 16 Q