3v4l.org

run code in 300+ PHP versions simultaneously
<?php $buffer = <<<XML <aaaa Version="1.0"> <bbb> <cccc> <dddd Id="id:pass" /> <eeee name="hearaman" age="24" /> </cccc> </bbb> </aaaa> XML; function XML2Array(SimpleXMLElement $parent) { $array = array(); foreach ($parent as $name => $element) { ($node = & $array[$name]) && (1 === count($node) ? $node = array($node) : 1) && $node = & $node[]; $node = $element->count() ? XML2Array($element) : trim($element); } return $array; } $xml = simplexml_load_string($buffer); $array = XML2Array($xml); $array = array($xml->getName() => $array); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l4nQN
function name:  (null)
number of ops:  17
compiled vars:  !0 = $buffer, !1 = $xml, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Caaaa+Version%3D%221.0%22%3E%0A+++%3Cbbb%3E%0A+++++%3Ccccc%3E%0A+++++++%3Cdddd+Id%3D%22id%3Apass%22+%2F%3E%0A+++++++%3Ceeee+name%3D%22hearaman%22+age%3D%2224%22+%2F%3E%0A+++++%3C%2Fcccc%3E%0A+++%3C%2Fbbb%3E%0A%3C%2Faaaa%3E'
   29     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   30     5        INIT_FCALL                                               'xml2array'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
   31     9        INIT_METHOD_CALL                                         !1, 'getName'
         10        DO_FCALL                                      0  $8      
         11        INIT_ARRAY                                       ~9      !2, $8
         12        ASSIGN                                                   !2, ~9
   33    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function xml2array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 35
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 35
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
Branch analysis from position: 21
Branch analysis from position: 17
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/l4nQN
function name:  XML2Array
number of ops:  38
compiled vars:  !0 = $parent, !1 = $array, !2 = $element, !3 = $name, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        ASSIGN                                                   !1, <array>
   18     2      > FE_RESET_R                                       $6      !0, ->35
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->35
          4    >   ASSIGN                                                   !3, ~7
   19     5        FETCH_DIM_W                                      $9      !1, !3
          6        ASSIGN_REF                                       $10     !4, $9
          7      > JMPZ_EX                                          ~11     $10, ->17
   20     8    >   COUNT                                            ~12     !4
          9        IS_IDENTICAL                                             ~12, 1
         10      > JMPZ                                                     ~13, ->15
         11    >   INIT_ARRAY                                       ~14     !4
         12        ASSIGN                                           ~15     !4, ~14
         13        QM_ASSIGN                                        ~16     ~15
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~16     1
         16    >   BOOL                                             ~11     ~16
         17    > > JMPZ_EX                                          ~11     ~11, ->21
   21    18    >   FETCH_DIM_W                                      $17     !4
         19        ASSIGN_REF                                       $18     !4, $17
         20        BOOL                                             ~11     $18
   23    21    >   INIT_METHOD_CALL                                         !2, 'count'
         22        DO_FCALL                                      0  $19     
         23      > JMPZ                                                     $19, ->29
         24    >   INIT_FCALL_BY_NAME                                       'XML2Array'
         25        SEND_VAR_EX                                              !2
         26        DO_FCALL                                      0  $20     
         27        QM_ASSIGN                                        ~21     $20
         28      > JMP                                                      ->33
         29    >   INIT_FCALL                                               'trim'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $22     
         32        QM_ASSIGN                                        ~21     $22
         33    >   ASSIGN                                                   !4, ~21
   18    34      > JMP                                                      ->3
         35    >   FE_FREE                                                  $6
   26    36      > RETURN                                                   !1
   27    37*     > RETURN                                                   null

End of function xml2array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.45 ms | 1403 KiB | 20 Q