3v4l.org

run code in 500+ 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 = 31
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 30
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 30
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/hLEFV
function name:  (null)
number of ops:  33
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, ->31
         12    > > FE_FETCH_R                                                   $13, !3, ->31
   26    13    >   INIT_METHOD_CALL                                             !3, 'getAttribute'
         14        SEND_VAL_EX                                                  'class'
         15        DO_FCALL                                          0  $14     
         16        FRAMELESS_ICALL_2                preg_match          ~15     '%2F%5Cbstyle124%5Cb%2F', $14
         17      > JMPZ                                                         ~15, ->30
   27    18    >   INIT_METHOD_CALL                                             !3, 'getElementsByTagName'
         19        SEND_VAL_EX                                                  'tr'
         20        DO_FCALL                                          0  $16     
         21        ASSIGN                                                       !4, $16
   28    22        FETCH_DIM_R                                          ~18     !4, 1
         23        INIT_METHOD_CALL                                             ~18, 'getElementsByTagName'
         24        SEND_VAL_EX                                                  'td'
         25        DO_FCALL                                          0  $19     
         26        ASSIGN                                                       !5, $19
   29    27        FETCH_DIM_R                                          ~21     !5, 0
         28        FETCH_OBJ_R                                          ~22     ~21, 'nodeValue'
         29        ECHO                                                         ~22
   25    30    > > JMP                                                          ->12
         31    >   FE_FREE                                                      $13
   31    32      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.68 ms | 1992 KiB | 13 Q