3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<html> <body> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD BGCOLOR=000000> <table> <td>Name</td> <td>Date</td> </tr> <tr> <td>Chad</td> <td>10/23/1996</td> </tr> <tr> <td>Rebecca</td> <td>05/03/2001</td> </table> </body> </html>'; $dom = new DOMDocument(); $dom->loadHTML($html); // Grab first table from dom and store its rows and columns by tag name. $rows = $dom->getElementsByTagName('table')->item(1)->getElementsByTagName('tr'); $headers = $rows->item(0); $resultArray = []; $keys = []; foreach($headers as $header) { $keys[] = strtolower($cell->nodeValue); } foreach($rows as $row) { $item = []; foreach($keys as $i=>$key) { $cells = $row->getElementsByTagName('td'); $item[$key] = $cells->item($i)->nodeValue; } $resultArray[] = $item; } print_r($resultArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 32
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 54
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 54
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 50
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 50
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 50
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 32
filename:       /in/3pPYb
function name:  (null)
number of ops:  59
compiled vars:  !0 = $html, !1 = $dom, !2 = $rows, !3 = $headers, !4 = $resultArray, !5 = $keys, !6 = $header, !7 = $cell, !8 = $row, !9 = $item, !10 = $key, !11 = $i, !12 = $cells
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%0A%3Cbody%3E%0A%3CTABLE+BORDER%3D0+CELLSPACING%3D0+CELLPADDING%3D0%3E+%3CTR%3E+%3CTD+BGCOLOR%3D000000%3E%0A++++%3Ctable%3E%0A++++++++++++++++%3Ctd%3EName%3C%2Ftd%3E%0A++++++++++++++++%3Ctd%3EDate%3C%2Ftd%3E%0A++++++++++++%3C%2Ftr%3E%0A++++++++++++%3Ctr%3E%0A++++++++++++++++%3Ctd%3EChad%3C%2Ftd%3E%0A++++++++++++++++%3Ctd%3E10%2F23%2F1996%3C%2Ftd%3E%0A++++++++++++%3C%2Ftr%3E%0A++++++++++++%3Ctr%3E%0A++++++++++++++++%3Ctd%3ERebecca%3C%2Ftd%3E%0A++++++++++++++++%3Ctd%3E05%2F03%2F2001%3C%2Ftd%3E%0A++++%3C%2Ftable%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   21     1        NEW                                              $14     'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $14
   22     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   25     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'table'
          9        DO_FCALL                                      0  $18     
         10        INIT_METHOD_CALL                                         $18, 'item'
         11        SEND_VAL_EX                                              1
         12        DO_FCALL                                      0  $19     
         13        INIT_METHOD_CALL                                         $19, 'getElementsByTagName'
         14        SEND_VAL_EX                                              'tr'
         15        DO_FCALL                                      0  $20     
         16        ASSIGN                                                   !2, $20
   26    17        INIT_METHOD_CALL                                         !2, 'item'
         18        SEND_VAL_EX                                              0
         19        DO_FCALL                                      0  $22     
         20        ASSIGN                                                   !3, $22
   28    21        ASSIGN                                                   !4, <array>
   29    22        ASSIGN                                                   !5, <array>
   31    23      > FE_RESET_R                                       $26     !3, ->32
         24    > > FE_FETCH_R                                               $26, !6, ->32
   32    25    >   INIT_FCALL                                               'strtolower'
         26        FETCH_OBJ_R                                      ~28     !7, 'nodeValue'
         27        SEND_VAL                                                 ~28
         28        DO_ICALL                                         $29     
         29        ASSIGN_DIM                                               !5
         30        OP_DATA                                                  $29
   31    31      > JMP                                                      ->24
         32    >   FE_FREE                                                  $26
   35    33      > FE_RESET_R                                       $30     !2, ->54
         34    > > FE_FETCH_R                                               $30, !8, ->54
   36    35    >   ASSIGN                                                   !9, <array>
   37    36      > FE_RESET_R                                       $32     !5, ->50
         37    > > FE_FETCH_R                                       ~33     $32, !10, ->50
         38    >   ASSIGN                                                   !11, ~33
   38    39        INIT_METHOD_CALL                                         !8, 'getElementsByTagName'
         40        SEND_VAL_EX                                              'td'
         41        DO_FCALL                                      0  $35     
         42        ASSIGN                                                   !12, $35
   39    43        INIT_METHOD_CALL                                         !12, 'item'
         44        SEND_VAR_EX                                              !11
         45        DO_FCALL                                      0  $38     
         46        FETCH_OBJ_R                                      ~39     $38, 'nodeValue'
         47        ASSIGN_DIM                                               !9, !10
         48        OP_DATA                                                  ~39
   37    49      > JMP                                                      ->37
         50    >   FE_FREE                                                  $32
   41    51        ASSIGN_DIM                                               !4
         52        OP_DATA                                                  !9
   35    53      > JMP                                                      ->34
         54    >   FE_FREE                                                  $30
   44    55        INIT_FCALL                                               'print_r'
         56        SEND_VAR                                                 !4
         57        DO_ICALL                                                 
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.43 ms | 1400 KiB | 17 Q