3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xml2array($xml){ $xml = simplexml_load_string(utf8_encode($xml)); $json = json_encode($xml); return json_decode($json,TRUE); } $xml1 = " <Root> <mounts> <names> <it>B</it> </names> </mounts> </Root> "; $xml2 = " <Root> <mounts> <names> <it>A</it> </names> </mounts> <mounts> <names> <it>A</it> </names> </mounts> </Root> "; echo '<pre>'; $arr1 = xml2array($xml1); $arr2 = xml2array($xml2); var_dump($arr1); var_dump($arr2); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jscVj
function name:  (null)
number of ops:  18
compiled vars:  !0 = $xml1, !1 = $xml2, !2 = $arr1, !3 = $arr2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, '%0A%3CRoot%3E%0A++++%3Cmounts%3E%0A++++++%3Cnames%3E%0A++++++++%3Cit%3EB%3C%2Fit%3E%0A++++++%3C%2Fnames%3E%0A++++%3C%2Fmounts%3E%0A%3C%2FRoot%3E%0A'
   19     1        ASSIGN                                                   !1, '%0A%3CRoot%3E%0A++++%3Cmounts%3E%0A++++++%3Cnames%3E%0A++++++++%3Cit%3EA%3C%2Fit%3E%0A++++++%3C%2Fnames%3E%0A++++%3C%2Fmounts%3E%0A++++%3Cmounts%3E%0A++++++%3Cnames%3E%0A++++++++%3Cit%3EA%3C%2Fit%3E%0A++++++%3C%2Fnames%3E%0A++++%3C%2Fmounts%3E%0A%3C%2FRoot%3E%0A'
   33     2        ECHO                                                     '%3Cpre%3E'
   34     3        INIT_FCALL                                               'xml2array'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !2, $6
   35     7        INIT_FCALL                                               'xml2array'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !3, $8
   36    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                                 
   37    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                                 
   43    17      > RETURN                                                   1

Function xml2array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jscVj
function name:  xml2array
number of ops:  18
compiled vars:  !0 = $xml, !1 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'simplexml_load_string'
          2        INIT_FCALL                                               'utf8_encode'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
    5     8        INIT_FCALL                                               'json_encode'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !1, $5
    6    12        INIT_FCALL                                               'json_decode'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $7      
         16      > RETURN                                                   $7
    7    17*     > RETURN                                                   null

End of function xml2array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151 ms | 1394 KiB | 25 Q