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]) && (is_array($node) ?: $node = array($node)) && $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/WuQeL
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 = 32
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 14
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/WuQeL
function name:  XML2Array
number of ops:  35
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, ->32
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->32
          4    >   ASSIGN                                                   !3, ~7
   18     5        FETCH_DIM_W                                      $9      !1, !3
          6        ASSIGN_REF                                       $10     !4, $9
          7      > JMPZ_EX                                          ~11     $10, ->14
   19     8    >   TYPE_CHECK                                  128  ~12     !4
          9        JMP_SET                                          ~13     ~12, ->13
         10        INIT_ARRAY                                       ~14     !4
         11        ASSIGN                                           ~15     !4, ~14
         12        QM_ASSIGN                                        ~13     ~15
         13        BOOL                                             ~11     ~13
         14    > > JMPZ_EX                                          ~11     ~11, ->18
   20    15    >   FETCH_DIM_W                                      $16     !4
         16        ASSIGN_REF                                       $17     !4, $16
         17        BOOL                                             ~11     $17
   22    18    >   INIT_METHOD_CALL                                         !2, 'count'
         19        DO_FCALL                                      0  $18     
         20      > JMPZ                                                     $18, ->26
         21    >   INIT_FCALL_BY_NAME                                       'XML2Array'
         22        SEND_VAR_EX                                              !2
         23        DO_FCALL                                      0  $19     
         24        QM_ASSIGN                                        ~20     $19
         25      > JMP                                                      ->30
         26    >   INIT_FCALL                                               'trim'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                         $21     
         29        QM_ASSIGN                                        ~20     $21
         30    >   ASSIGN                                                   !4, ~20
   17    31      > JMP                                                      ->3
         32    >   FE_FREE                                                  $6
   25    33      > RETURN                                                   !1
   26    34*     > RETURN                                                   null

End of function xml2array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.62 ms | 1009 KiB | 17 Q