3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Just compose the HTML sample */ $html='<html><head></head><body><table id="myTable">'; for($i=0;$i<100;$i++) { $html.="<tr><td>info{$i}.1</td><td>info{$i}.2</td><td>info{$i}.3</td></tr>"; } $html.="</table></body></html>"; $doc=new DOMDocument(); $doc->loadHTML($html); $xpath=new DOMXPath($doc); echo "<table>\n"; /* 10 is the row count */ for($i=0;$i<10;$i++) { echo "<tr>\n"; /* 10 is the column count */ foreach($xpath->query('//table[@id="myTable"]/tr[position()>'.($i*10).' and position()<'.(($i+1)*10+1).']') as $tr) { echo "\t<td>";// "\t" to make it look nice $tds=array(); foreach($tr->childNodes as $td) { if($td->nodeName!="td") continue; $tds[]=$td->firstChild->nodeValue; } echo implode("<br />",$tds); echo "</td>\n"; } echo "</tr>\n"; } echo "</table>";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 69, Position 2 = 28
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 64
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 64
Branch analysis from position: 42
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 56
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 56
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 51
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 56
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 69, Position 2 = 28
Branch analysis from position: 69
Branch analysis from position: 28
Branch analysis from position: 64
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
Branch analysis from position: 3
filename:       /in/lrOLg
function name:  (null)
number of ops:  71
compiled vars:  !0 = $html, !1 = $i, !2 = $doc, !3 = $xpath, !4 = $tr, !5 = $tds, !6 = $td
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3Ctable+id%3D%22myTable%22%3E'
    4     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->12
    6     3    >   ROPE_INIT                                     7  ~10     '%3Ctr%3E%3Ctd%3Einfo'
          4        ROPE_ADD                                      1  ~10     ~10, !1
          5        ROPE_ADD                                      2  ~10     ~10, '.1%3C%2Ftd%3E%3Ctd%3Einfo'
          6        ROPE_ADD                                      3  ~10     ~10, !1
          7        ROPE_ADD                                      4  ~10     ~10, '.2%3C%2Ftd%3E%3Ctd%3Einfo'
          8        ROPE_ADD                                      5  ~10     ~10, !1
          9        ROPE_END                                      6  ~9      ~10, '.3%3C%2Ftd%3E%3C%2Ftr%3E'
         10        ASSIGN_OP                                     8          !0, ~9
    4    11        PRE_INC                                                  !1
         12    >   IS_SMALLER                                               !1, 100
         13      > JMPNZ                                                    ~16, ->3
    8    14    >   ASSIGN_OP                                     8          !0, '%3C%2Ftable%3E%3C%2Fbody%3E%3C%2Fhtml%3E'
    9    15        NEW                                              $18     'DOMDocument'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !2, $18
   10    18        INIT_METHOD_CALL                                         !2, 'loadHTML'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0          
   11    21        NEW                                              $22     'DOMXPath'
         22        SEND_VAR_EX                                              !2
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !3, $22
   12    25        ECHO                                                     '%3Ctable%3E%0A'
   14    26        ASSIGN                                                   !1, 0
         27      > JMP                                                      ->67
   16    28    >   ECHO                                                     '%3Ctr%3E%0A'
   18    29        INIT_METHOD_CALL                                         !3, 'query'
         30        MUL                                              ~26     !1, 10
         31        CONCAT                                           ~27     '%2F%2Ftable%5B%40id%3D%22myTable%22%5D%2Ftr%5Bposition%28%29%3E', ~26
         32        CONCAT                                           ~28     ~27, '+and+position%28%29%3C'
         33        ADD                                              ~29     !1, 1
         34        MUL                                              ~30     ~29, 10
         35        ADD                                              ~31     ~30, 1
         36        CONCAT                                           ~32     ~28, ~31
         37        CONCAT                                           ~33     ~32, '%5D'
         38        SEND_VAL_EX                                              ~33
         39        DO_FCALL                                      0  $34     
         40      > FE_RESET_R                                       $35     $34, ->64
         41    > > FE_FETCH_R                                               $35, !4, ->64
   20    42    >   ECHO                                                     '%09%3Ctd%3E'
   21    43        ASSIGN                                                   !5, <array>
   22    44        FETCH_OBJ_R                                      ~37     !4, 'childNodes'
         45      > FE_RESET_R                                       $38     ~37, ->56
         46    > > FE_FETCH_R                                               $38, !6, ->56
   24    47    >   FETCH_OBJ_R                                      ~39     !6, 'nodeName'
         48        IS_NOT_EQUAL                                             ~39, 'td'
         49      > JMPZ                                                     ~40, ->51
         50    > > JMP                                                      ->46
   25    51    >   FETCH_OBJ_R                                      ~42     !6, 'firstChild'
         52        FETCH_OBJ_R                                      ~43     ~42, 'nodeValue'
         53        ASSIGN_DIM                                               !5
         54        OP_DATA                                                  ~43
   22    55      > JMP                                                      ->46
         56    >   FE_FREE                                                  $38
   27    57        INIT_FCALL                                               'implode'
         58        SEND_VAL                                                 '%3Cbr+%2F%3E'
         59        SEND_VAR                                                 !5
         60        DO_ICALL                                         $44     
         61        ECHO                                                     $44
   28    62        ECHO                                                     '%3C%2Ftd%3E%0A'
   18    63      > JMP                                                      ->41
         64    >   FE_FREE                                                  $35
   30    65        ECHO                                                     '%3C%2Ftr%3E%0A'
   14    66        PRE_INC                                                  !1
         67    >   IS_SMALLER                                               !1, 10
         68      > JMPNZ                                                    ~46, ->28
   32    69    >   ECHO                                                     '%3C%2Ftable%3E'
         70      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
214.09 ms | 1408 KiB | 15 Q