3v4l.org

run code in 300+ PHP versions simultaneously
<?php $XML = <<< XML <root> <item>1</item> <item>2</item> <item>3</item> </root> XML; $dom = new DomDocument(); $dom->loadXml($XML); $items = $dom->getElementsByTagName('item'); echo "Count: {$items->length}", PHP_EOL; foreach ($items as $k => $item) { print "K: ".$k." Item: ".$item->nodeName. " Value: ".$item->nodeValue. PHP_EOL; } print "----" . PHP_EOL; $it = new IteratorIterator($dom->getElementsByTagName('item')); $c = iterator_count($it); echo "Count: $c", PHP_EOL; foreach ($it as $k => $item) { print "K: ".$k." Item: ".$item->nodeName. " Value: ".$item->nodeValue. PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 59
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 59
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 29
filename:       /in/LtSmU
function name:  (null)
number of ops:  61
compiled vars:  !0 = $XML, !1 = $dom, !2 = $items, !3 = $item, !4 = $k, !5 = $it, !6 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Croot%3E%0A++%3Citem%3E1%3C%2Fitem%3E%0A++%3Citem%3E2%3C%2Fitem%3E%0A++%3Citem%3E3%3C%2Fitem%3E%0A%3C%2Froot%3E'
   10     1        NEW                                              $8      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
   11     4        INIT_METHOD_CALL                                         !1, 'loadXml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   12     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'item'
          9        DO_FCALL                                      0  $12     
         10        ASSIGN                                                   !2, $12
   14    11        NOP                                                      
         12        FETCH_OBJ_R                                      ~14     !2, 'length'
         13        FAST_CONCAT                                      ~15     'Count%3A+', ~14
         14        ECHO                                                     ~15
         15        ECHO                                                     '%0A'
   15    16      > FE_RESET_R                                       $16     !2, ->29
         17    > > FE_FETCH_R                                       ~17     $16, !3, ->29
         18    >   ASSIGN                                                   !4, ~17
   16    19        CONCAT                                           ~19     'K%3A+', !4
         20        CONCAT                                           ~20     ~19, '++Item%3A+'
         21        FETCH_OBJ_R                                      ~21     !3, 'nodeName'
         22        CONCAT                                           ~22     ~20, ~21
         23        CONCAT                                           ~23     ~22, '+Value%3A+'
         24        FETCH_OBJ_R                                      ~24     !3, 'nodeValue'
         25        CONCAT                                           ~25     ~23, ~24
         26        CONCAT                                           ~26     ~25, '%0A'
         27        ECHO                                                     ~26
   15    28      > JMP                                                      ->17
         29    >   FE_FREE                                                  $16
   19    30        ECHO                                                     '----%0A'
   20    31        NEW                                              $27     'IteratorIterator'
         32        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         33        SEND_VAL_EX                                              'item'
         34        DO_FCALL                                      0  $28     
         35        SEND_VAR_NO_REF_EX                                       $28
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !5, $27
   21    38        INIT_FCALL                                               'iterator_count'
         39        SEND_VAR                                                 !5
         40        DO_ICALL                                         $31     
         41        ASSIGN                                                   !6, $31
   22    42        NOP                                                      
         43        FAST_CONCAT                                      ~33     'Count%3A+', !6
         44        ECHO                                                     ~33
         45        ECHO                                                     '%0A'
   23    46      > FE_RESET_R                                       $34     !5, ->59
         47    > > FE_FETCH_R                                       ~35     $34, !3, ->59
         48    >   ASSIGN                                                   !4, ~35
   24    49        CONCAT                                           ~37     'K%3A+', !4
         50        CONCAT                                           ~38     ~37, '++Item%3A+'
         51        FETCH_OBJ_R                                      ~39     !3, 'nodeName'
         52        CONCAT                                           ~40     ~38, ~39
         53        CONCAT                                           ~41     ~40, '+Value%3A+'
         54        FETCH_OBJ_R                                      ~42     !3, 'nodeValue'
         55        CONCAT                                           ~43     ~41, ~42
         56        CONCAT                                           ~44     ~43, '%0A'
         57        ECHO                                                     ~44
   23    58      > JMP                                                      ->47
         59    >   FE_FREE                                                  $34
   25    60      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.69 ms | 1400 KiB | 15 Q