3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOF <div id="box"> <tr align='center'> <td>1</td> <td style='padding-left: 0px !important;padding-right: 10px !important;'> <div id=''></div></td> <td>45</td> <td>62</td> </tr><tr align='center'> <td>2</td> <td style='padding-left: 0px !important;padding-right: 10px !important;'> <div id=''></div></td> <td>35</td> <td>47</td> </tr><tr align='center'> <td>3</td> <td style='padding-left: 0px !important;padding-right: 10px !important;'> <div id=''></div></td> <td>63</td> <td>58</td> </tr> EOF; $url = ''; $doc = new DOMDocument(); $doc->preserveWhiteSpace = FALSE; @$doc->loadHTML($html); $xpath = new DOMXpath ($doc); $expresion = "//div[@id='box']//tr"; $trs = $xpath->evaluate($expresion); foreach ($trs as $tr) { $tdvals = array(); foreach($xpath->query('td', $tr) as $td) { /* Skip the td with the empty text value */ if(trim($td->nodeValue) !== '') { $tdvals []= $td->nodeValue; } } echo implode(',', $tdvals) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 48
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 48
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 40
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 40
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 39
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 39
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 40
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/aD7U7
function name:  (null)
number of ops:  50
compiled vars:  !0 = $html, !1 = $url, !2 = $doc, !3 = $xpath, !4 = $expresion, !5 = $trs, !6 = $tr, !7 = $tdvals, !8 = $td
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+id%3D%22box%22%3E%0A%3Ctr+align%3D%27center%27%3E%0A%3Ctd%3E1%3C%2Ftd%3E%0A%3Ctd+style%3D%27padding-left%3A+0px+%21important%3Bpadding-right%3A+10px+%21important%3B%27%3E+++%3Cdiv+id%3D%27%27%3E%3C%2Fdiv%3E%3C%2Ftd%3E%0A%3Ctd%3E45%3C%2Ftd%3E%0A%3Ctd%3E62%3C%2Ftd%3E%0A%3C%2Ftr%3E%3Ctr+align%3D%27center%27%3E%0A%3Ctd%3E2%3C%2Ftd%3E%0A%3Ctd+style%3D%27padding-left%3A+0px+%21important%3Bpadding-right%3A+10px+%21important%3B%27%3E+++%3Cdiv+id%3D%27%27%3E%3C%2Fdiv%3E%3C%2Ftd%3E%0A%3Ctd%3E35%3C%2Ftd%3E%0A%3Ctd%3E47%3C%2Ftd%3E%0A%3C%2Ftr%3E%3Ctr+align%3D%27center%27%3E%0A%3Ctd%3E3%3C%2Ftd%3E%0A%3Ctd+style%3D%27padding-left%3A+0px+%21important%3Bpadding-right%3A+10px+%21important%3B%27%3E+++%3Cdiv+id%3D%27%27%3E%3C%2Fdiv%3E%3C%2Ftd%3E%0A%3Ctd%3E63%3C%2Ftd%3E%0A%3Ctd%3E58%3C%2Ftd%3E%0A%3C%2Ftr%3E'
   23     1        ASSIGN                                                   !1, ''
   24     2        NEW                                              $11     'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $11
   25     5        ASSIGN_OBJ                                               !2, 'preserveWhiteSpace'
          6        OP_DATA                                                  <false>
   26     7        BEGIN_SILENCE                                    ~15     
          8        INIT_METHOD_CALL                                         !2, 'loadHTML'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        END_SILENCE                                              ~15
   27    12        NEW                                              $17     'DOMXpath'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !3, $17
   28    16        ASSIGN                                                   !4, '%2F%2Fdiv%5B%40id%3D%27box%27%5D%2F%2Ftr'
   29    17        INIT_METHOD_CALL                                         !3, 'evaluate'
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0  $21     
         20        ASSIGN                                                   !5, $21
   30    21      > FE_RESET_R                                       $23     !5, ->48
         22    > > FE_FETCH_R                                               $23, !6, ->48
   32    23    >   ASSIGN                                                   !7, <array>
   33    24        INIT_METHOD_CALL                                         !3, 'query'
         25        SEND_VAL_EX                                              'td'
         26        SEND_VAR_EX                                              !6
         27        DO_FCALL                                      0  $25     
         28      > FE_RESET_R                                       $26     $25, ->40
         29    > > FE_FETCH_R                                               $26, !8, ->40
   35    30    >   INIT_FCALL                                               'trim'
         31        FETCH_OBJ_R                                      ~27     !8, 'nodeValue'
         32        SEND_VAL                                                 ~27
         33        DO_ICALL                                         $28     
         34        IS_NOT_IDENTICAL                                         $28, ''
         35      > JMPZ                                                     ~29, ->39
   36    36    >   FETCH_OBJ_R                                      ~31     !8, 'nodeValue'
         37        ASSIGN_DIM                                               !7
         38        OP_DATA                                                  ~31
   33    39    > > JMP                                                      ->29
         40    >   FE_FREE                                                  $26
   39    41        INIT_FCALL                                               'implode'
         42        SEND_VAL                                                 '%2C'
         43        SEND_VAR                                                 !7
         44        DO_ICALL                                         $32     
         45        CONCAT                                           ~33     $32, '%0A'
         46        ECHO                                                     ~33
   30    47      > JMP                                                      ->22
         48    >   FE_FREE                                                  $23
   40    49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.73 ms | 1016 KiB | 15 Q