3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<< XML <?xml version="1.0" encoding="utf-8"?> <books> <book>Patterns of Enterprise Application Architecture</book> <book></book> <book>Design Patterns: Elements of Reusable Software Design</book> <book>Clean Code</book> </books> XML; $dom = new DOMDocument; $dom->loadXML($xml); $books = $dom->getElementsByTagName('book'); $length = $books->length; $break = FALSE; foreach ($books as $k => $book) { if($break){ if($k == ($length-1)) { echo "last iteration: " . $book->nodeValue; } else { contiune; } } if(empty($book->nodeValue)) { $break = TRUE; contiune; } echo $book->nodeValue, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 36
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 36
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 32
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
Branch analysis from position: 32
Branch analysis from position: 27
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/9ba49
function name:  (null)
number of ops:  38
compiled vars:  !0 = $xml, !1 = $dom, !2 = $books, !3 = $length, !4 = $break, !5 = $book, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22%3F%3E%0A%3Cbooks%3E%0A+%3Cbook%3EPatterns+of+Enterprise+Application+Architecture%3C%2Fbook%3E%0A+%3Cbook%3E%3C%2Fbook%3E%0A+%3Cbook%3EDesign+Patterns%3A+Elements+of+Reusable+Software+Design%3C%2Fbook%3E%0A+%3Cbook%3EClean+Code%3C%2Fbook%3E%0A%3C%2Fbooks%3E'
   13     1        NEW                                              $8      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
   14     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   15     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'book'
          9        DO_FCALL                                      0  $12     
         10        ASSIGN                                                   !2, $12
   16    11        FETCH_OBJ_R                                      ~14     !2, 'length'
         12        ASSIGN                                                   !3, ~14
   17    13        ASSIGN                                                   !4, <false>
   18    14      > FE_RESET_R                                       $17     !2, ->36
         15    > > FE_FETCH_R                                       ~18     $17, !5, ->36
         16    >   ASSIGN                                                   !6, ~18
   20    17      > JMPZ                                                     !4, ->27
   22    18    >   SUB                                              ~20     !3, 1
         19        IS_EQUAL                                                 !6, ~20
         20      > JMPZ                                                     ~21, ->25
   23    21    >   FETCH_OBJ_R                                      ~22     !5, 'nodeValue'
         22        CONCAT                                           ~23     'last+iteration%3A+', ~22
         23        ECHO                                                     ~23
         24      > JMP                                                      ->27
   25    25    >   FETCH_CONSTANT                                   ~24     'contiune'
         26        FREE                                                     ~24
   30    27    >   ISSET_ISEMPTY_PROP_OBJ                                   !5, 'nodeValue'
         28      > JMPZ                                                     ~25, ->32
   31    29    >   ASSIGN                                                   !4, <true>
   32    30        FETCH_CONSTANT                                   ~27     'contiune'
         31        FREE                                                     ~27
   36    32    >   FETCH_OBJ_R                                      ~28     !5, 'nodeValue'
         33        ECHO                                                     ~28
         34        ECHO                                                     '%0A'
   18    35      > JMP                                                      ->15
         36    >   FE_FREE                                                  $17
   37    37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.83 ms | 1399 KiB | 13 Q