3v4l.org

run code in 300+ PHP versions simultaneously
<?php $simpsons[0] = array("name"=>"Abe","parent"=>-1); $simpsons[1] = array("name"=>"Homer","parent"=>0); // Homer's parent is Abe $simpsons[2] = array("name"=>"Bart","parent"=>1); // Bart's parent is Homer $simpsons[3] = array("name"=>"Lisa","parent"=>1); // Lisa's parent is Homer $simpsons[4] = array("name"=>"Maggie","parent"=>1); // Maggie's parent is Homer function get_children($parent) { global $simpsons; reset($simpsons); foreach ($simpsons as $index=>$onesimpson) { if ($onesimpson["parent"]==$parent) { echo "$onesimpson[name] is a child of ".$simpsons[$parent]["name"].".<br />\n"; get_children($index); } } } get_children(0); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dvhsD
function name:  (null)
number of ops:  14
compiled vars:  !0 = $simpsons
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN_DIM                                               !0, 0
          1        OP_DATA                                                  <array>
    3     2        ASSIGN_DIM                                               !0, 1
          3        OP_DATA                                                  <array>
    4     4        ASSIGN_DIM                                               !0, 2
          5        OP_DATA                                                  <array>
    5     6        ASSIGN_DIM                                               !0, 3
          7        OP_DATA                                                  <array>
    6     8        ASSIGN_DIM                                               !0, 4
          9        OP_DATA                                                  <array>
   21    10        INIT_FCALL                                               'get_children'
         11        SEND_VAL                                                 0
         12        DO_FCALL                                      0          
   22    13      > RETURN                                                   1

Function get_children:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 23
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 22
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/dvhsD
function name:  get_children
number of ops:  25
compiled vars:  !0 = $parent, !1 = $simpsons, !2 = $onesimpson, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        BIND_GLOBAL                                              !1, 'simpsons'
   11     2        INIT_FCALL                                               'reset'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                                 
   13     5      > FE_RESET_R                                       $5      !1, ->23
          6    > > FE_FETCH_R                                       ~6      $5, !2, ->23
          7    >   ASSIGN                                                   !3, ~6
   14     8        FETCH_DIM_R                                      ~8      !2, 'parent'
          9        IS_EQUAL                                                 !0, ~8
         10      > JMPZ                                                     ~9, ->22
   15    11    >   FETCH_DIM_R                                      ~10     !2, 'name'
         12        NOP                                                      
         13        FAST_CONCAT                                      ~11     ~10, '+is+a+child+of+'
         14        FETCH_DIM_R                                      ~12     !1, !0
         15        FETCH_DIM_R                                      ~13     ~12, 'name'
         16        CONCAT                                           ~14     ~11, ~13
         17        CONCAT                                           ~15     ~14, '.%3Cbr+%2F%3E%0A'
         18        ECHO                                                     ~15
   16    19        INIT_FCALL_BY_NAME                                       'get_children'
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0          
   13    22    > > JMP                                                      ->6
         23    >   FE_FREE                                                  $5
   19    24      > RETURN                                                   null

End of function get_children

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.55 ms | 1403 KiB | 16 Q