3v4l.org

run code in 300+ 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) { $result[] = [ 'name' => $row->getElementsByTagName('th')->item(0)->nodeValue, 'value' => $row->getElementsByTagName('td')->item(0)->nodeValue, ]; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 32
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 32
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/WaYvK
function name:  (null)
number of ops:  37
compiled vars:  !0 = $html, !1 = $dom, !2 = $result, !3 = $row
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                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   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  $10     
         11      > FE_RESET_R                                       $11     $10, ->32
         12    > > FE_FETCH_R                                               $11, !3, ->32
   21    13    >   INIT_METHOD_CALL                                         !3, 'getElementsByTagName'
         14        SEND_VAL_EX                                              'th'
         15        DO_FCALL                                      0  $13     
         16        INIT_METHOD_CALL                                         $13, 'item'
         17        SEND_VAL_EX                                              0
         18        DO_FCALL                                      0  $14     
         19        FETCH_OBJ_R                                      ~15     $14, 'nodeValue'
         20        INIT_ARRAY                                       ~16     ~15, 'name'
   22    21        INIT_METHOD_CALL                                         !3, 'getElementsByTagName'
         22        SEND_VAL_EX                                              'td'
         23        DO_FCALL                                      0  $17     
         24        INIT_METHOD_CALL                                         $17, 'item'
         25        SEND_VAL_EX                                              0
         26        DO_FCALL                                      0  $18     
         27        FETCH_OBJ_R                                      ~19     $18, 'nodeValue'
         28        ADD_ARRAY_ELEMENT                                ~16     ~19, 'value'
   20    29        ASSIGN_DIM                                               !2
   22    30        OP_DATA                                                  ~16
   19    31      > JMP                                                      ->12
         32    >   FE_FREE                                                  $11
   25    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.58 ms | 998 KiB | 14 Q