3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<EOL <document> <test> <foo>2</foo> <bar>hello</bar> </test> <test> <foo>5</foo> <bar attr="value">bye</bar> </test> </document> EOL; libxml_use_internal_errors(true); $dom = new DomDocument; $dom->recover = true; if(!$dom->loadXML($xml)) die('Error happened'); $nodesTest = $dom->getElementsByTagName('test'); $res = array(); foreach($nodesTest as $test) { $foo = $test->getElementsByTagName('foo'); $bar = $test->getElementsByTagName('bar'); if($foo->length === 1 && $bar->length === 1) { $x = array($bar->item(0)->nodeValue); if($bar->item(0)->hasAttribute('attr')) $x[] = $bar->item(0)->getAttribute('attr'); $res[$foo->item(0)->nodeValue] = $x; } } var_dump($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 65
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 65
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 33, Position 2 = 36
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 64
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 58
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 58
Branch analysis from position: 64
Branch analysis from position: 36
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
filename:       /in/d4YVv
function name:  (null)
number of ops:  70
compiled vars:  !0 = $xml, !1 = $dom, !2 = $nodesTest, !3 = $res, !4 = $test, !5 = $foo, !6 = $bar, !7 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdocument%3E%0A++++%3Ctest%3E%0A++++++++%3Cfoo%3E2%3C%2Ffoo%3E%0A++++++++%3Cbar%3Ehello%3C%2Fbar%3E%0A++++%3C%2Ftest%3E%0A++++%3Ctest%3E%0A++++++++%3Cfoo%3E5%3C%2Ffoo%3E%0A++++++++%3Cbar+attr%3D%22value%22%3Ebye%3C%2Fbar%3E%0A++++%3C%2Ftest%3E%0A%3C%2Fdocument%3E'
   16     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
   17     4        NEW                                              $10     'DomDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $10
   18     7        ASSIGN_OBJ                                               !1, 'recover'
          8        OP_DATA                                                  <true>
   20     9        INIT_METHOD_CALL                                         !1, 'loadXML'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $14     
         12        BOOL_NOT                                         ~15     $14
         13      > JMPZ                                                     ~15, ->15
   21    14    > > EXIT                                                     'Error+happened'
   23    15    >   INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         16        SEND_VAL_EX                                              'test'
         17        DO_FCALL                                      0  $16     
         18        ASSIGN                                                   !2, $16
   24    19        ASSIGN                                                   !3, <array>
   26    20      > FE_RESET_R                                       $19     !2, ->65
         21    > > FE_FETCH_R                                               $19, !4, ->65
   27    22    >   INIT_METHOD_CALL                                         !4, 'getElementsByTagName'
         23        SEND_VAL_EX                                              'foo'
         24        DO_FCALL                                      0  $20     
         25        ASSIGN                                                   !5, $20
   28    26        INIT_METHOD_CALL                                         !4, 'getElementsByTagName'
         27        SEND_VAL_EX                                              'bar'
         28        DO_FCALL                                      0  $22     
         29        ASSIGN                                                   !6, $22
   30    30        FETCH_OBJ_R                                      ~24     !5, 'length'
         31        IS_IDENTICAL                                     ~25     ~24, 1
         32      > JMPZ_EX                                          ~25     ~25, ->36
         33    >   FETCH_OBJ_R                                      ~26     !6, 'length'
         34        IS_IDENTICAL                                     ~27     ~26, 1
         35        BOOL                                             ~25     ~27
         36    > > JMPZ                                                     ~25, ->64
   31    37    >   INIT_METHOD_CALL                                         !6, 'item'
         38        SEND_VAL_EX                                              0
         39        DO_FCALL                                      0  $28     
         40        FETCH_OBJ_R                                      ~29     $28, 'nodeValue'
         41        INIT_ARRAY                                       ~30     ~29
         42        ASSIGN                                                   !7, ~30
   32    43        INIT_METHOD_CALL                                         !6, 'item'
         44        SEND_VAL_EX                                              0
         45        DO_FCALL                                      0  $32     
         46        INIT_METHOD_CALL                                         $32, 'hasAttribute'
         47        SEND_VAL_EX                                              'attr'
         48        DO_FCALL                                      0  $33     
         49      > JMPZ                                                     $33, ->58
   33    50    >   INIT_METHOD_CALL                                         !6, 'item'
         51        SEND_VAL_EX                                              0
         52        DO_FCALL                                      0  $35     
         53        INIT_METHOD_CALL                                         $35, 'getAttribute'
         54        SEND_VAL_EX                                              'attr'
         55        DO_FCALL                                      0  $36     
         56        ASSIGN_DIM                                               !7
         57        OP_DATA                                                  $36
   35    58    >   INIT_METHOD_CALL                                         !5, 'item'
         59        SEND_VAL_EX                                              0
         60        DO_FCALL                                      0  $37     
         61        FETCH_OBJ_R                                      ~38     $37, 'nodeValue'
         62        ASSIGN_DIM                                               !3, ~38
         63        OP_DATA                                                  !7
   26    64    > > JMP                                                      ->21
         65    >   FE_FREE                                                  $19
   40    66        INIT_FCALL                                               'var_dump'
         67        SEND_VAR                                                 !3
         68        DO_ICALL                                                 
         69      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.13 ms | 1405 KiB | 17 Q