3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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']; } else { get_hierarchy($regions, $regions[$region_id]['parent_id']); } return $regions[$region_id]['name']; } var_dump(get_hierarchy($regions, 44));
based on 6jk7s
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/MF1HT
function name:  (null)
number of ops:  21
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>
  12    12        NOP                                                      
  26    13        INIT_FCALL                                               'var_dump'
        14        INIT_FCALL                                               'get_hierarchy'
        15        SEND_VAR                                                 !0
        16        SEND_VAL                                                 44
        17        DO_FCALL                                      0  $9      
        18        SEND_VAR                                                 $9
        19        DO_ICALL                                                 
        20      > RETURN                                                   1

Function get_hierarchy:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
Jump found. Position 1 = -2
Branch analysis from position: 10
Jump found. Position 1 = -2
filename:       /in/MF1HT
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                                     ~4      0, $3
         5      > JMPZ                                                     ~4, ->10
  16     6    >   FETCH_DIM_R                                      $5      !0, !1
         7        FETCH_DIM_R                                      $6      $5, 'name'
         8      > RETURN                                                   $6
         9*       JMP                                                      ->16
  20    10    >   INIT_FCALL_BY_NAME                                       'get_hierarchy'
        11        SEND_VAR_EX                                              !0
        12        FETCH_DIM_FUNC_ARG                               $7      !0, !1
        13        FETCH_DIM_FUNC_ARG                               $8      $7, 'parent_id'
        14        SEND_VAR_EX                                              $8
        15        DO_FCALL                                      0          
  23    16        FETCH_DIM_R                                      $10     !0, !1
        17        FETCH_DIM_R                                      $11     $10, 'name'
        18      > RETURN                                                   $11
  24    19*     > RETURN                                                   null

End of function get_hierarchy

Generated using Vulcan Logic Dumper, using php 7.3.0