3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <table border="0" cellpadding="0" cellspacing="0" width="100%" class="Table2"> <tbody><tr> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="65%" valign="top" class="Title2">Subject</td> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="14%" valign="top" align="Center" class="Title2">Last Update</td> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="8%" valign="top" align="Center" class="Title2">Replies</td> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="9%" valign="top" align="Center" class="Title2">Views</td> </tr> <tr> <td width="1%" height="25">&nbsp;</td> <td width="64%" height="25" class="FootNotes2"><a href="/files/forum/2017/1/837110.php" target="_top" class="Links2">Serious dedicated study partner for U World</a> - step12013</td> <td width="1%" height="25">&nbsp;</td> <td width="14%" height="25" class="FootNotes2" align="center">02/11/17 01:50</td> <td width="1%" height="25">&nbsp;</td> <td width="8%" height="25" align="Center" class="FootNotes2">10</td> <td width="1%" height="25">&nbsp;</td> <td width="9%" height="25" align="Center" class="FootNotes2">318</td> </tr> <tr> <td width="1%" height="25">&nbsp;</td> <td width="64%" height="25" class="FootNotes2"><a href="/files/forum/2017/1/837999.php" target="_top" class="Links2">some text</a> - step12013</td> <td width="1%" height="25">&nbsp;</td> <td width="14%" height="25" class="FootNotes2" align="center">02/11/17 01:50</td> <td width="1%" height="25">&nbsp;</td> <td width="8%" height="25" align="Center" class="FootNotes2">10</td> <td width="1%" height="25">&nbsp;</td> <td width="9%" height="25" align="Center" class="FootNotes2">318</td> </tr> </tbody> </table> HTML; $dom=new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); foreach ($xpath->evaluate("//td[@class = 'FootNotes2']/a") as $node) { // target a tags that have <td class="FootNotes2"> as parent $result[]=['href' => $node->getAttribute('href'), 'text' => $node->nodeValue]; // extract/store the href and text values if (sizeof($result) == 10) { break; } // set a limit of 10 rows of data } if (isset($result)) { echo "<ul>\n"; foreach ($result as $data) { echo "\t<li class=\"itemtitle\"><a href=\"{$data['href']}\" target=\"_blank\">{$data['text']}</a></li>\n"; } echo "</ul>"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 29
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 29
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 28
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 46
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 44
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 46
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 29
Branch analysis from position: 29
filename:       /in/nXB2q
function name:  (null)
number of ops:  47
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $node, !4 = $result, !5 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ctable+border%3D%220%22+cellpadding%3D%220%22+cellspacing%3D%220%22+width%3D%22100%25%22+class%3D%22Table2%22%3E%0A%3Ctbody%3E%3Ctr%3E%0A++++%3Ctd+width%3D%221%25%22+valign%3D%22top%22+class%3D%22Title2%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%2265%25%22+valign%3D%22top%22+class%3D%22Title2%22%3ESubject%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+valign%3D%22top%22+class%3D%22Title2%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%2214%25%22+valign%3D%22top%22+align%3D%22Center%22+class%3D%22Title2%22%3ELast+Update%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+valign%3D%22top%22+class%3D%22Title2%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%228%25%22+valign%3D%22top%22+align%3D%22Center%22+class%3D%22Title2%22%3EReplies%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+valign%3D%22top%22+class%3D%22Title2%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%229%25%22+valign%3D%22top%22+align%3D%22Center%22+class%3D%22Title2%22%3EViews%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3Ctr%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%2264%25%22+height%3D%2225%22+class%3D%22FootNotes2%22%3E%3Ca+href%3D%22%2Ffiles%2Fforum%2F2017%2F1%2F837110.php%22+target%3D%22_top%22+class%3D%22Links2%22%3ESerious+dedicated+study+partner+for+U+World%3C%2Fa%3E+-+step12013%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%2214%25%22+height%3D%2225%22+class%3D%22FootNotes2%22+align%3D%22center%22%3E02%2F11%2F17+01%3A50%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%228%25%22+height%3D%2225%22+align%3D%22Center%22+class%3D%22FootNotes2%22%3E10%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%229%25%22+height%3D%2225%22+align%3D%22Center%22+class%3D%22FootNotes2%22%3E318%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3Ctr%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%2264%25%22+height%3D%2225%22+class%3D%22FootNotes2%22%3E%3Ca+href%3D%22%2Ffiles%2Fforum%2F2017%2F1%2F837999.php%22+target%3D%22_top%22+class%3D%22Links2%22%3Esome+text%3C%2Fa%3E+-+step12013%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%2214%25%22+height%3D%2225%22+class%3D%22FootNotes2%22+align%3D%22center%22%3E02%2F11%2F17+01%3A50%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%228%25%22+height%3D%2225%22+align%3D%22Center%22+class%3D%22FootNotes2%22%3E10%3C%2Ftd%3E%0A++++%3Ctd+width%3D%221%25%22+height%3D%2225%22%3E%26nbsp%3B%3C%2Ftd%3E%0A++++%3Ctd+width%3D%229%25%22+height%3D%2225%22+align%3D%22Center%22+class%3D%22FootNotes2%22%3E318%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3C%2Ftbody%3E%0A%3C%2Ftable%3E'
   38     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   39     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   40     7        NEW                                              $11     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $11
   41    11        INIT_METHOD_CALL                                         !2, 'evaluate'
         12        SEND_VAL_EX                                              '%2F%2Ftd%5B%40class+%3D+%27FootNotes2%27%5D%2Fa'
         13        DO_FCALL                                      0  $14     
         14      > FE_RESET_R                                       $15     $14, ->29
         15    > > FE_FETCH_R                                               $15, !3, ->29
   42    16    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         17        SEND_VAL_EX                                              'href'
         18        DO_FCALL                                      0  $17     
         19        INIT_ARRAY                                       ~18     $17, 'href'
         20        FETCH_OBJ_R                                      ~19     !3, 'nodeValue'
         21        ADD_ARRAY_ELEMENT                                ~18     ~19, 'text'
         22        ASSIGN_DIM                                               !4
         23        OP_DATA                                                  ~18
   43    24        COUNT                                            ~20     !4
         25        IS_EQUAL                                                 ~20, 10
         26      > JMPZ                                                     ~21, ->28
         27    > > JMP                                                      ->29
   41    28    > > JMP                                                      ->15
         29    >   FE_FREE                                                  $15
   45    30        ISSET_ISEMPTY_CV                                         !4
         31      > JMPZ                                                     ~22, ->46
   46    32    >   ECHO                                                     '%3Cul%3E%0A'
   47    33      > FE_RESET_R                                       $23     !4, ->44
         34    > > FE_FETCH_R                                               $23, !5, ->44
   48    35    >   ROPE_INIT                                     5  ~27     '%09%3Cli+class%3D%22itemtitle%22%3E%3Ca+href%3D%22'
         36        FETCH_DIM_R                                      ~24     !5, 'href'
         37        ROPE_ADD                                      1  ~27     ~27, ~24
         38        ROPE_ADD                                      2  ~27     ~27, '%22+target%3D%22_blank%22%3E'
         39        FETCH_DIM_R                                      ~25     !5, 'text'
         40        ROPE_ADD                                      3  ~27     ~27, ~25
         41        ROPE_END                                      4  ~26     ~27, '%3C%2Fa%3E%3C%2Fli%3E%0A'
         42        ECHO                                                     ~26
   47    43      > JMP                                                      ->34
         44    >   FE_FREE                                                  $23
   50    45        ECHO                                                     '%3C%2Ful%3E'
   51    46    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.23 ms | 1016 KiB | 13 Q