3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = new SimpleXMLElement('<root><elements attr="test"><el>test1</el><el>test2</el><el test_attr="123">test3</el></elements></root>'); //print_r(json_decode(json_encode((array) simplexml_load_string($xml)), 1)); function xml2array ( $xmlObject ) { $out = array (); foreach ( (array) $xmlObject as $index => $node ) $out[$index] = ( is_object ( $node ) ) ? xml2array ( $node ) : $node; return $out; } print_r(xml2array($xml));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lNQS2
function name:  (null)
number of ops:  11
compiled vars:  !0 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $1      'SimpleXMLElement'
          1        SEND_VAL_EX                                              '%3Croot%3E%3Celements+attr%3D%22test%22%3E%3Cel%3Etest1%3C%2Fel%3E%3Cel%3Etest2%3C%2Fel%3E%3Cel+test_attr%3D%22123%22%3Etest3%3C%2Fel%3E%3C%2Felements%3E%3C%2Froot%3E'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   15     4        INIT_FCALL                                               'print_r'
          5        INIT_FCALL                                               'xml2array'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function xml2array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/lNQS2
function name:  xml2array
number of ops:  20
compiled vars:  !0 = $xmlObject, !1 = $out, !2 = $node, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN                                                   !1, <array>
    9     2        CAST                                          7  ~5      !0
          3      > FE_RESET_R                                       $6      ~5, ->17
          4    > > FE_FETCH_R                                       ~7      $6, !2, ->17
          5    >   ASSIGN                                                   !3, ~7
   10     6        TYPE_CHECK                                  256          !2
          7      > JMPZ                                                     ~10, ->13
          8    >   INIT_FCALL_BY_NAME                                       'xml2array'
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0  $11     
         11        QM_ASSIGN                                        ~12     $11
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~12     !2
         14    >   ASSIGN_DIM                                               !1, !3
         15        OP_DATA                                                  ~12
    9    16      > JMP                                                      ->4
         17    >   FE_FREE                                                  $6
   12    18      > RETURN                                                   !1
   13    19*     > RETURN                                                   null

End of function xml2array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.06 ms | 1403 KiB | 16 Q