3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<table> <tbody> <tr><tr> <tr> <td> <table class="style124"> <tbody> <tr> <td>A</td> </tr> <tr> <td>B</td> //THIS !! </tr> </tbody> </table> </td> </tr> <tr></tr> </tbody> </table>'; $dom = new DOMDocument; $dom->loadHTML($html); $tables = $dom->getElementsByTagName('table'); foreach($tables as $table){ if(preg_match('/\bstyle124\b/', $table->getAttribute('class'))){ $trs = $table->getElementsByTagName('tr'); $tds = $trs[1]->getElementsByTagName('td'); echo $tds[0]->nodeValue; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 34
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 34
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 33
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 33
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/hLEFV
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $dom, !2 = $tables, !3 = $table, !4 = $trs, !5 = $tds
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ctable%3E%0A++%3Ctbody%3E%0A++++%3Ctr%3E%3Ctr%3E%0A++++%3Ctr%3E%0A++++++++%3Ctd%3E+%0A++++++++++++%3Ctable+class%3D%22style124%22%3E%0A++++++++++++++++%3Ctbody%3E%0A++++++++++++++++++++%3Ctr%3E%0A++++++++++++++++++++++++%3Ctd%3EA%3C%2Ftd%3E%0A++++++++++++++++++++%3C%2Ftr%3E%0A++++++++++++++++++++%3Ctr%3E%0A++++++++++++++++++++++++%3Ctd%3EB%3C%2Ftd%3E+%2F%2FTHIS+%21%21%0A++++++++++++++++++++%3C%2Ftr%3E%0A++++++++++++++++%3C%2Ftbody%3E%0A++++++++++++%3C%2Ftable%3E%0A++++++++%3C%2Ftd%3E%0A++++%3C%2Ftr%3E%0A++++%3Ctr%3E%3C%2Ftr%3E%0A++%3C%2Ftbody%3E%0A%3C%2Ftable%3E'
   22     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   23     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   24     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'table'
          9        DO_FCALL                                      0  $11     
         10        ASSIGN                                                   !2, $11
   25    11      > FE_RESET_R                                       $13     !2, ->34
         12    > > FE_FETCH_R                                               $13, !3, ->34
   26    13    >   INIT_FCALL                                               'preg_match'
         14        SEND_VAL                                                 '%2F%5Cbstyle124%5Cb%2F'
         15        INIT_METHOD_CALL                                         !3, 'getAttribute'
         16        SEND_VAL_EX                                              'class'
         17        DO_FCALL                                      0  $14     
         18        SEND_VAR                                                 $14
         19        DO_ICALL                                         $15     
         20      > JMPZ                                                     $15, ->33
   27    21    >   INIT_METHOD_CALL                                         !3, 'getElementsByTagName'
         22        SEND_VAL_EX                                              'tr'
         23        DO_FCALL                                      0  $16     
         24        ASSIGN                                                   !4, $16
   28    25        FETCH_DIM_R                                      ~18     !4, 1
         26        INIT_METHOD_CALL                                         ~18, 'getElementsByTagName'
         27        SEND_VAL_EX                                              'td'
         28        DO_FCALL                                      0  $19     
         29        ASSIGN                                                   !5, $19
   29    30        FETCH_DIM_R                                      ~21     !5, 0
         31        FETCH_OBJ_R                                      ~22     ~21, 'nodeValue'
         32        ECHO                                                     ~22
   25    33    > > JMP                                                      ->12
         34    >   FE_FREE                                                  $13
   31    35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.63 ms | 1007 KiB | 14 Q