3v4l.org

run code in 300+ PHP versions simultaneously
<?php function create_tree($arr,$pid=0) { $arr = array( array('id'=>1,'pid'=>'0','name'=>'11111'), array('id'=>2,'pid'=>'1','name'=>'22222'), array('id'=>3,'pid'=>'0','name'=>'33333'), array('id'=>4,'pid'=>'3','name'=>'44444'), array('id'=>5,'pid'=>'4','name'=>'55555'), array('id'=>6,'pid'=>'1','name'=>'66666') ); $ret = array(); foreach($arr as $k => $v) { if($v['pid'] == $pid) { $tmp = $arr[$k];unset($arr[$k]); $tmp['children'] = create_tree($arr,$v['id']); $ret[] = $tmp; } } return $ret; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S8kKL
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E > > RETURN                                                   1

Function create_tree:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 24
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 24
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/S8kKL
function name:  create_tree
number of ops:  27
compiled vars:  !0 = $arr, !1 = $pid, !2 = $ret, !3 = $v, !4 = $k, !5 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
    3     2        ASSIGN                                                   !0, <array>
   11     3        ASSIGN                                                   !2, <array>
   12     4      > FE_RESET_R                                       $8      !0, ->24
          5    > > FE_FETCH_R                                       ~9      $8, !3, ->24
          6    >   ASSIGN                                                   !4, ~9
   13     7        FETCH_DIM_R                                      ~11     !3, 'pid'
          8        IS_EQUAL                                                 !1, ~11
          9      > JMPZ                                                     ~12, ->23
   14    10    >   FETCH_DIM_R                                      ~13     !0, !4
         11        ASSIGN                                                   !5, ~13
         12        UNSET_DIM                                                !0, !4
   15    13        INIT_FCALL_BY_NAME                                       'create_tree'
         14        SEND_VAR_EX                                              !0
         15        CHECK_FUNC_ARG                                           
         16        FETCH_DIM_FUNC_ARG                               $16     !3, 'id'
         17        SEND_FUNC_ARG                                            $16
         18        DO_FCALL                                      0  $17     
         19        ASSIGN_DIM                                               !5, 'children'
         20        OP_DATA                                                  $17
   16    21        ASSIGN_DIM                                               !2
         22        OP_DATA                                                  !5
   12    23    > > JMP                                                      ->5
         24    >   FE_FREE                                                  $8
   19    25      > RETURN                                                   !2
   20    26*     > RETURN                                                   null

End of function create_tree

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.45 ms | 1395 KiB | 13 Q