3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>'. '<request><body test2="321" test3="987">'. '<rows><my-row test4="564">'. '<types>'. '<custom>this is the example of the text</custom>'. '<Generic arch="simple">this is the example of the text</Generic>'. '<bold/><italic/><underlined/>'. '</types>'. '</my-row><my-row test5="565"/><test hidden="false" ready="true"/></rows>'. '</body></request>'; function f($xml, $stack = null) { $stack = count($stack) ? $stack : array(); foreach ($xml as $key => $value) { $stack[$key] = null; if (count($value->attributes())) $stack[$key]['attributes'] = (array)$value->attributes(); if (is_string($value)) $stack[$key]['content'] = (string)$value; /*print_r(array( 'key' => $key, 'hasChildren' => (bool)$xml->hasChildren(), 'attributes' => (array)$value->attributes(), 'stack' => $s, ));*/ var_dump(get_class($value), $stack); if (get_class($value) == 'SimpleXMLIterator') f($value, $stack); } return $s; } print_r(f(new SimpleXMLIterator($s)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iYQdj
function name:  (null)
number of ops:  11
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22+standalone%3D%22yes%22+%3F%3E%3Crequest%3E%3Cbody+test2%3D%22321%22+test3%3D%22987%22%3E%3Crows%3E%3Cmy-row+test4%3D%22564%22%3E%3Ctypes%3E%3Ccustom%3Ethis+is+the+example+of+the+text%3C%2Fcustom%3E%3CGeneric+arch%3D%22simple%22%3Ethis+is+the+example+of+the+text%3C%2FGeneric%3E%3Cbold%2F%3E%3Citalic%2F%3E%3Cunderlined%2F%3E%3C%2Ftypes%3E%3C%2Fmy-row%3E%3Cmy-row+test5%3D%22565%22%2F%3E%3Ctest+hidden%3D%22false%22+ready%3D%22true%22%2F%3E%3C%2Frows%3E%3C%2Fbody%3E%3C%2Frequest%3E'
   34     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'f'
          3        NEW                                              $2      'SimpleXMLIterator'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        SEND_VAR                                                 $2
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function f:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 42
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 42
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 41
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 42
Branch analysis from position: 9
Branch analysis from position: 42
filename:       /in/iYQdj
function name:  f
number of ops:  45
compiled vars:  !0 = $xml, !1 = $stack, !2 = $value, !3 = $key, !4 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   14     2        COUNT                                            ~5      !1
          3      > JMPZ                                                     ~5, ->6
          4    >   QM_ASSIGN                                        ~6      !1
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~6      <array>
          7    >   ASSIGN                                                   !1, ~6
   15     8      > FE_RESET_R                                       $8      !0, ->42
          9    > > FE_FETCH_R                                       ~9      $8, !2, ->42
         10    >   ASSIGN                                                   !3, ~9
   16    11        ASSIGN_DIM                                               !1, !3
         12        OP_DATA                                                  null
   17    13        INIT_METHOD_CALL                                         !2, 'attributes'
         14        DO_FCALL                                      0  $12     
         15        COUNT                                            ~13     $12
         16      > JMPZ                                                     ~13, ->23
   18    17    >   INIT_METHOD_CALL                                         !2, 'attributes'
         18        DO_FCALL                                      0  $16     
         19        CAST                                          7  ~17     $16
         20        FETCH_DIM_W                                      $14     !1, !3
         21        ASSIGN_DIM                                               $14, 'attributes'
         22        OP_DATA                                                  ~17
   19    23    >   TYPE_CHECK                                   64          !2
         24      > JMPZ                                                     ~18, ->29
   20    25    >   CAST                                          6  ~21     !2
         26        FETCH_DIM_W                                      $19     !1, !3
         27        ASSIGN_DIM                                               $19, 'content'
         28        OP_DATA                                                  ~21
   27    29    >   INIT_FCALL                                               'var_dump'
         30        GET_CLASS                                        ~22     !2
         31        SEND_VAL                                                 ~22
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                                 
   28    34        GET_CLASS                                        ~24     !2
         35        IS_EQUAL                                                 ~24, 'SimpleXMLIterator'
         36      > JMPZ                                                     ~25, ->41
         37    >   INIT_FCALL_BY_NAME                                       'f'
         38        SEND_VAR_EX                                              !2
         39        SEND_VAR_EX                                              !1
         40        DO_FCALL                                      0          
   15    41    > > JMP                                                      ->9
         42    >   FE_FREE                                                  $8
   30    43      > RETURN                                                   !4
   31    44*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.12 ms | 1402 KiB | 18 Q