3v4l.org

run code in 300+ PHP versions simultaneously
<?php function Recurse1($xml) { foreach ($xml->children() as $child) { if (is_iterable($child)) { if (!isset($array)) { $array = Recurse1($child); } else { $array = array_merge($array, Recurse1($child)); } } else { $array[] = (string)$xml['role']; } } 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/Q1n9j
function name:  (null)
number of ops:  11
compiled vars:  !0 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $1      'SimpleXMLElement'
   20     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          
   19     3        ASSIGN                                                   !0, $1
   30     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 = 4, Position 2 = 31
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 31
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/Q1n9j
function name:  Recurse1
number of ops:  34
compiled vars:  !0 = $xml, !1 = $child, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_METHOD_CALL                                         !0, 'children'
          2        DO_FCALL                                      0  $3      
          3      > FE_RESET_R                                       $4      $3, ->31
          4    > > FE_FETCH_R                                               $4, !1, ->31
    6     5    >   INIT_FCALL                                               'is_iterable'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8      > JMPZ                                                     $5, ->26
    7     9    >   ISSET_ISEMPTY_CV                                 ~6      !2
         10        BOOL_NOT                                         ~7      ~6
         11      > JMPZ                                                     ~7, ->17
    8    12    >   INIT_FCALL_BY_NAME                                       'Recurse1'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0  $8      
         15        ASSIGN                                                   !2, $8
         16      > JMP                                                      ->25
   10    17    >   INIT_FCALL                                               'array_merge'
         18        SEND_VAR                                                 !2
         19        INIT_FCALL_BY_NAME                                       'Recurse1'
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $10     
         22        SEND_VAR                                                 $10
         23        DO_ICALL                                         $11     
         24        ASSIGN                                                   !2, $11
         25    > > JMP                                                      ->30
   13    26    >   FETCH_DIM_R                                      ~14     !0, 'role'
         27        CAST                                          6  ~15     ~14
         28        ASSIGN_DIM                                               !2
         29        OP_DATA                                                  ~15
    4    30    > > JMP                                                      ->4
         31    >   FE_FREE                                                  $4
   16    32      > RETURN                                                   !2
   17    33*     > RETURN                                                   null

End of function recurse1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.5 ms | 1403 KiB | 20 Q