3v4l.org

run code in 300+ PHP versions simultaneously
<?php $buffer = <<<XML <pages> <item>about-porto</item> <item>about-porto-4</item> <item>no-route-2</item> <item>porto_home_4</item> <item>porto_home_4_old</item> </pages> 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/Oqr5c
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, '%3Cpages%3E%0A++++%3Citem%3Eabout-porto%3C%2Fitem%3E%0A++++%3Citem%3Eabout-porto-4%3C%2Fitem%3E%0A++++%3Citem%3Eno-route-2%3C%2Fitem%3E%0A++++%3Citem%3Eporto_home_4%3C%2Fitem%3E%0A++++%3Citem%3Eporto_home_4_old%3C%2Fitem%3E%0A%3C%2Fpages%3E'
   28     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   29     5        INIT_FCALL                                               'xml2array'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
   30     9        INIT_METHOD_CALL                                         !1, 'getName'
         10        DO_FCALL                                      0  $8      
         11        INIT_ARRAY                                       ~9      !2, $8
         12        ASSIGN                                                   !2, ~9
   32    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/Oqr5c
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
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, <array>
   17     2      > FE_RESET_R                                       $6      !0, ->35
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->35
          4    >   ASSIGN                                                   !3, ~7
   18     5        FETCH_DIM_W                                      $9      !1, !3
          6        ASSIGN_REF                                       $10     !4, $9
          7      > JMPZ_EX                                          ~11     $10, ->17
   19     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
   20    18    >   FETCH_DIM_W                                      $17     !4
         19        ASSIGN_REF                                       $18     !4, $17
         20        BOOL                                             ~11     $18
   22    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
   17    34      > JMP                                                      ->3
         35    >   FE_FREE                                                  $6
   25    36      > RETURN                                                   !1
   26    37*     > RETURN                                                   null

End of function xml2array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.76 ms | 1009 KiB | 17 Q