3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<HTML <table> <tr> <th>test1</th> <td>test1-1</td> </tr> <tr> <th>test2</th> <td>test2-2</td> </tr> </table> HTML; $dom = new DOMDocument(); $dom->loadHTML($html); $result = []; foreach ($dom->getElementsByTagName('tr') as $row) { $tags = $row->getElementsByTagName('*'); $result[] = [ 'name' => $tags->item(0)->nodeValue, 'value' => $tags->item(1)->nodeValue, ]; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 30
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 30
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/GhoVO
function name:  (null)
number of ops:  35
compiled vars:  !0 = $html, !1 = $dom, !2 = $result, !3 = $row, !4 = $tags
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Ctable%3E%0A++%3Ctr%3E%0A++++%3Cth%3Etest1%3C%2Fth%3E%0A++++%3Ctd%3Etest1-1%3C%2Ftd%3E%0A++%3C%2Ftr%3E%0A++%3Ctr%3E%0A++++%3Cth%3Etest2%3C%2Fth%3E%0A++++%3Ctd%3Etest2-2%3C%2Ftd%3E%0A++%3C%2Ftr%3E%0A%3C%2Ftable%3E'
   16     1        NEW                                                  $6      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $6
   17     4        INIT_METHOD_CALL                                             !1, 'loadHTML'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
   18     7        ASSIGN                                                       !2, <array>
   19     8        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
          9        SEND_VAL_EX                                                  'tr'
         10        DO_FCALL                                          0  $11     
         11      > FE_RESET_R                                           $12     $11, ->30
         12    > > FE_FETCH_R                                                   $12, !3, ->30
   20    13    >   INIT_METHOD_CALL                                             !3, 'getElementsByTagName'
         14        SEND_VAL_EX                                                  '%2A'
         15        DO_FCALL                                          0  $13     
         16        ASSIGN                                                       !4, $13
   22    17        INIT_METHOD_CALL                                             !4, 'item'
         18        SEND_VAL_EX                                                  0
         19        DO_FCALL                                          0  $16     
         20        FETCH_OBJ_R                                          ~17     $16, 'nodeValue'
         21        INIT_ARRAY                                           ~18     ~17, 'name'
   23    22        INIT_METHOD_CALL                                             !4, 'item'
         23        SEND_VAL_EX                                                  1
         24        DO_FCALL                                          0  $19     
         25        FETCH_OBJ_R                                          ~20     $19, 'nodeValue'
         26        ADD_ARRAY_ELEMENT                                    ~18     ~20, 'value'
   21    27        ASSIGN_DIM                                                   !2
   23    28        OP_DATA                                                      ~18
   19    29      > JMP                                                          ->12
         30    >   FE_FREE                                                      $12
   26    31        INIT_FCALL                                                   'var_export'
         32        SEND_VAR                                                     !2
         33        DO_ICALL                                                     
         34      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.11 ms | 1733 KiB | 14 Q