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) { print_r(array( 'call', $stack )); $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, ));*/ print_r(array( 'call', $value, )); if (get_class($value) == 'SimpleXMLIterator' && $xml->hasChildren()) f($xml->getChildren(), $stack); } return $stack; } print_r(f(new SimpleXMLIterator($s)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RJWCn
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'
   42     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 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 53
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 53
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 42, Position 2 = 45
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 52
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 52
Branch analysis from position: 45
Branch analysis from position: 34
Branch analysis from position: 28
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 53
Branch analysis from position: 14
Branch analysis from position: 53
filename:       /in/RJWCn
function name:  f
number of ops:  56
compiled vars:  !0 = $xml, !1 = $stack, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   14     2        INIT_FCALL                                               'print_r'
   15     3        INIT_ARRAY                                       ~4      'call'
   16     4        ADD_ARRAY_ELEMENT                                ~4      !1
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
   18     7        COUNT                                            ~6      !1
          8      > JMPZ                                                     ~6, ->11
          9    >   QM_ASSIGN                                        ~7      !1
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~7      <array>
         12    >   ASSIGN                                                   !1, ~7
   19    13      > FE_RESET_R                                       $9      !0, ->53
         14    > > FE_FETCH_R                                       ~10     $9, !2, ->53
         15    >   ASSIGN                                                   !3, ~10
   20    16        ASSIGN_DIM                                               !1, !3
         17        OP_DATA                                                  null
   21    18        INIT_METHOD_CALL                                         !2, 'attributes'
         19        DO_FCALL                                      0  $13     
         20        COUNT                                            ~14     $13
         21      > JMPZ                                                     ~14, ->28
   22    22    >   INIT_METHOD_CALL                                         !2, 'attributes'
         23        DO_FCALL                                      0  $17     
         24        CAST                                          7  ~18     $17
         25        FETCH_DIM_W                                      $15     !1, !3
         26        ASSIGN_DIM                                               $15, 'attributes'
         27        OP_DATA                                                  ~18
   23    28    >   TYPE_CHECK                                   64          !2
         29      > JMPZ                                                     ~19, ->34
   24    30    >   CAST                                          6  ~22     !2
         31        FETCH_DIM_W                                      $20     !1, !3
         32        ASSIGN_DIM                                               $20, 'content'
         33        OP_DATA                                                  ~22
   31    34    >   INIT_FCALL                                               'print_r'
   32    35        INIT_ARRAY                                       ~23     'call'
   33    36        ADD_ARRAY_ELEMENT                                ~23     !2
         37        SEND_VAL                                                 ~23
         38        DO_ICALL                                                 
   35    39        GET_CLASS                                        ~25     !2
         40        IS_EQUAL                                         ~26     ~25, 'SimpleXMLIterator'
         41      > JMPZ_EX                                          ~26     ~26, ->45
         42    >   INIT_METHOD_CALL                                         !0, 'hasChildren'
         43        DO_FCALL                                      0  $27     
         44        BOOL                                             ~26     $27
         45    > > JMPZ                                                     ~26, ->52
   36    46    >   INIT_FCALL_BY_NAME                                       'f'
         47        INIT_METHOD_CALL                                         !0, 'getChildren'
         48        DO_FCALL                                      0  $28     
         49        SEND_VAR_NO_REF_EX                                       $28
         50        SEND_VAR_EX                                              !1
         51        DO_FCALL                                      0          
   19    52    > > JMP                                                      ->14
         53    >   FE_FREE                                                  $9
   38    54      > RETURN                                                   !1
   39    55*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.63 ms | 1403 KiB | 16 Q