3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regions = array(); $regions[65] = array('id' => 65, 'parent_id' => 44, 'name' => "Shoreditch"); $regions[77] = array('id' => 77, 'parent_id' => 5, 'name' => "England"); $regions[100] = array('id' => 100, 'parent_id' => 0, 'name' => "Europe"); $regions[5] = array('id' => 5, 'parent_id' => 100, 'name' => "United Kingdom"); $regions[44] = array('id' => 44, 'parent_id' => 77, 'name' => "London"); $hierarchy = array(); function get_hierarchy($regions, $region_id = 0) { if (0 === $regions[$region_id]['parent_id']) { return $regions[$region_id]['name']; } get_hierarchy($regions, $regions[$region_id]['parent_id']); return $regions[$region_id]['name']; } var_dump(get_hierarchy($regions, 44));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6jk7s
function name:  (null)
number of ops:  20
compiled vars:  !0 = $regions, !1 = $hierarchy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN_DIM                                               !0, 65
          2        OP_DATA                                                  <array>
    5     3        ASSIGN_DIM                                               !0, 77
          4        OP_DATA                                                  <array>
    6     5        ASSIGN_DIM                                               !0, 100
          6        OP_DATA                                                  <array>
    7     7        ASSIGN_DIM                                               !0, 5
          8        OP_DATA                                                  <array>
    8     9        ASSIGN_DIM                                               !0, 44
         10        OP_DATA                                                  <array>
   10    11        ASSIGN                                                   !1, <array>
   24    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'get_hierarchy'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 44
         16        DO_FCALL                                      0  $9      
         17        SEND_VAR                                                 $9
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function get_hierarchy:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6jk7s
function name:  get_hierarchy
number of ops:  20
compiled vars:  !0 = $regions, !1 = $region_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   14     2        FETCH_DIM_R                                      ~2      !0, !1
          3        FETCH_DIM_R                                      ~3      ~2, 'parent_id'
          4        IS_IDENTICAL                                             ~3, 0
          5      > JMPZ                                                     ~4, ->9
   16     6    >   FETCH_DIM_R                                      ~5      !0, !1
          7        FETCH_DIM_R                                      ~6      ~5, 'name'
          8      > RETURN                                                   ~6
   19     9    >   INIT_FCALL_BY_NAME                                       'get_hierarchy'
         10        SEND_VAR_EX                                              !0
         11        CHECK_FUNC_ARG                                           
         12        FETCH_DIM_FUNC_ARG                               $7      !0, !1
         13        FETCH_DIM_FUNC_ARG                               $8      $7, 'parent_id'
         14        SEND_FUNC_ARG                                            $8
         15        DO_FCALL                                      0          
   21    16        FETCH_DIM_R                                      ~10     !0, !1
         17        FETCH_DIM_R                                      ~11     ~10, 'name'
         18      > RETURN                                                   ~11
   22    19*     > RETURN                                                   null

End of function get_hierarchy

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.87 ms | 1403 KiB | 16 Q