3v4l.org

run code in 300+ PHP versions simultaneously
<?php function Recurse1($xml) { $array = [(string)$xml['role']]; foreach ($xml->children() as $child) { $array = array_merge($array, Recurse1($child)); } return $array; } $xml = new SimpleXMLElement( '<person> <child role="son1"> <child role="daughter1"/> </child> <child role="daughter2"> <child role="son2"> <child role="son3"/> </child> </child> </person>'); var_dump(Recurse1($xml));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tIIND
function name:  (null)
number of ops:  11
compiled vars:  !0 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $1      'SimpleXMLElement'
   14     1        SEND_VAL_EX                                              '%3Cperson%3E%0A%3Cchild+role%3D%22son1%22%3E%0A%3Cchild+role%3D%22daughter1%22%2F%3E%0A%3C%2Fchild%3E%0A%3Cchild+role%3D%22daughter2%22%3E%0A%3Cchild+role%3D%22son2%22%3E%0A%3Cchild+role%3D%22son3%22%2F%3E%0A%3C%2Fchild%3E%0A%3C%2Fchild%3E%0A%3C%2Fperson%3E'
          2        DO_FCALL                                      0          
   13     3        ASSIGN                                                   !0, $1
   24     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'recurse1'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function recurse1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/tIIND
function name:  Recurse1
number of ops:  21
compiled vars:  !0 = $xml, !1 = $array, !2 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        FETCH_DIM_R                                      ~3      !0, 'role'
          2        CAST                                          6  ~4      ~3
          3        INIT_ARRAY                                       ~5      ~4
          4        ASSIGN                                                   !1, ~5
    5     5        INIT_METHOD_CALL                                         !0, 'children'
          6        DO_FCALL                                      0  $7      
          7      > FE_RESET_R                                       $8      $7, ->18
          8    > > FE_FETCH_R                                               $8, !2, ->18
    7     9    >   INIT_FCALL                                               'array_merge'
         10        SEND_VAR                                                 !1
         11        INIT_FCALL_BY_NAME                                       'Recurse1'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR                                                 $9
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !1, $10
    5    17      > JMP                                                      ->8
         18    >   FE_FREE                                                  $8
   10    19      > RETURN                                                   !1
   11    20*     > RETURN                                                   null

End of function recurse1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.75 ms | 1399 KiB | 18 Q