3v4l.org

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

End of function recurse1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.24 ms | 1402 KiB | 20 Q