3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); global $n; $n=0; function convert($xml) { $simpleXmlObj = simplexml_load_string($xml); $array = toarray($simpleXmlObj); return $array; } function toarray($simpleXmlObj) { $simpleXmlObjNew = array(); foreach (array_keys((array)$simpleXmlObj) as $element) { $el = (array)$simpleXmlObj->$element; if(isset($el[0])){ $trim = $el[0]; $simpleXmlObjNew[$element] = $trim; }else{ $simpleXmlObjNew[$element] = toarray($simpleXmlObj->$element); } if(empty( $simpleXmlObjNew[$element] )){ $simpleXmlObjNew[$element] = ''; } } return $simpleXmlObjNew; } $xml = <<<xml <?xml version="1.0" encoding="utf-8"?> <RESPONSE> <e></e> <e1> </e1> <e2> s </e2> <e3>s</e3> <e4> </e4> </RESPONSE> xml; $simpleXmlObj = simplexml_load_string($xml); $response = toarray($simpleXmlObj); print_r($response);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uDm6Z
function name:  (null)
number of ops:  18
compiled vars:  !0 = $n, !1 = $xml, !2 = $simpleXmlObj, !3 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    4     3        BIND_GLOBAL                                              !0, 'n'
    5     4        ASSIGN                                                   !0, 0
   33     5        ASSIGN                                                   !1, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22%3F%3E%0A%3CRESPONSE%3E%0A++%3Ce%3E%3C%2Fe%3E%0A++%3Ce1%3E++%3C%2Fe1%3E%0A++%3Ce2%3E+s+%3C%2Fe2%3E%0A++%3Ce3%3Es%3C%2Fe3%3E%0A++%3Ce4%3E%0A++%3C%2Fe4%3E%0A%3C%2FRESPONSE%3E'
   45     6        INIT_FCALL                                               'simplexml_load_string'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
   46    10        INIT_FCALL                                               'toarray'
         11        SEND_VAR                                                 !2
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !3, $9
   47    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function convert:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uDm6Z
function name:  convert
number of ops:  11
compiled vars:  !0 = $xml, !1 = $simpleXmlObj, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   10     5        INIT_FCALL_BY_NAME                                       'toarray'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $5      
          8        ASSIGN                                                   !2, $5
   11     9      > RETURN                                                   !2
   12    10*     > RETURN                                                   null

End of function convert

Function toarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 30
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 30
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/uDm6Z
function name:  toarray
number of ops:  33
compiled vars:  !0 = $simpleXmlObj, !1 = $simpleXmlObjNew, !2 = $element, !3 = $el, !4 = $trim
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        ASSIGN                                                   !1, <array>
   17     2        INIT_FCALL                                               'array_keys'
          3        CAST                                          7  ~6      !0
          4        SEND_VAL                                                 ~6
          5        DO_ICALL                                         $7      
          6      > FE_RESET_R                                       $8      $7, ->30
          7    > > FE_FETCH_R                                               $8, !2, ->30
   18     8    >   FETCH_OBJ_R                                      ~9      !0, !2
          9        CAST                                          7  ~10     ~9
         10        ASSIGN                                                   !3, ~10
   19    11        ISSET_ISEMPTY_DIM_OBJ                         0          !3, 0
         12      > JMPZ                                                     ~12, ->18
   20    13    >   FETCH_DIM_R                                      ~13     !3, 0
         14        ASSIGN                                                   !4, ~13
   21    15        ASSIGN_DIM                                               !1, !2
         16        OP_DATA                                                  !4
         17      > JMP                                                      ->25
   24    18    >   INIT_FCALL_BY_NAME                                       'toarray'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_OBJ_FUNC_ARG                               $17     !0, !2
         21        SEND_FUNC_ARG                                            $17
         22        DO_FCALL                                      0  $18     
         23        ASSIGN_DIM                                               !1, !2
         24        OP_DATA                                                  $18
   26    25    >   ISSET_ISEMPTY_DIM_OBJ                         1          !1, !2
         26      > JMPZ                                                     ~19, ->29
   27    27    >   ASSIGN_DIM                                               !1, !2
         28        OP_DATA                                                  ''
   17    29    > > JMP                                                      ->7
         30    >   FE_FREE                                                  $8
   30    31      > RETURN                                                   !1
   31    32*     > RETURN                                                   null

End of function toarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.15 ms | 1394 KiB | 22 Q