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> </td> //THIS !! </tr> </tbody> </table> </td> </tr> <tr></tr> </tbody> </table>'; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $query = '//table[contains(@class, "style124")]/tbody/tr[2]/td'; $entries = $xpath->query($query); foreach($entries as $entry){ if(empty(trim($entry->nodeValue))){ echo 'no value'; } else { echo $entry->nodeValue; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/h0H8q
function name:  (null)
number of ops:  31
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $query, !4 = $entries, !5 = $entry
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%3E+++++%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        NEW                                              $11     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $11
   25    11        ASSIGN                                                   !3, '%2F%2Ftable%5Bcontains%28%40class%2C+%22style124%22%29%5D%2Ftbody%2Ftr%5B2%5D%2Ftd'
   26    12        INIT_METHOD_CALL                                         !2, 'query'
         13        SEND_VAR_EX                                              !3
         14        DO_FCALL                                      0  $15     
         15        ASSIGN                                                   !4, $15
   27    16      > FE_RESET_R                                       $17     !4, ->29
         17    > > FE_FETCH_R                                               $17, !5, ->29
   28    18    >   INIT_FCALL                                               'trim'
         19        FETCH_OBJ_R                                      ~18     !5, 'nodeValue'
         20        SEND_VAL                                                 ~18
         21        DO_ICALL                                         $19     
         22        BOOL_NOT                                         ~20     $19
         23      > JMPZ                                                     ~20, ->26
   29    24    >   ECHO                                                     'no+value'
   28    25      > JMP                                                      ->28
   31    26    >   FETCH_OBJ_R                                      ~21     !5, 'nodeValue'
         27        ECHO                                                     ~21
   27    28    > > JMP                                                      ->17
         29    >   FE_FREE                                                  $17
   33    30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.61 ms | 1015 KiB | 14 Q