3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<table id="transactions" class="table"> <thead> <tr> <th class="image"></th> <th class="title"><span>Title</span></th> </tr> </thead> <tbody> <tr class="tbody-tr"> <td class="image"> <img src="http://www.example.com/image.jpg"> </td> <td class="title">Title </td> <td class="date">12/16/2017 </td> </tr> <tr class="tbody-tr"> <td class="image"> <img src="http://www.example.com/image.jpg"> </td> <td class="title">Title </td> <td class="date">12/16/2017 </td> </tr> </tbody> </table>'; $doc = new DOMDocument(); $doc->loadHTML($html); $doc->formatOutput = true; foreach ($doc->getElementsByTagName('tr') as $tr) { $td = $doc->createElement('td'); $td->setAttribute('class', 'example'); $tr->insertBefore($td, $tr->childNodes->item(3)); } echo $doc->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 31
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/TthE7
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $doc, !2 = $tr, !3 = $td
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ctable+id%3D%22transactions%22+class%3D%22table%22%3E%0A++++%3Cthead%3E%0A++++++++%3Ctr%3E%0A++++++++++++%3Cth+class%3D%22image%22%3E%3C%2Fth%3E%0A++++++++++++%3Cth+class%3D%22title%22%3E%3Cspan%3ETitle%3C%2Fspan%3E%3C%2Fth%3E%0A++++++++%3C%2Ftr%3E%0A++++%3C%2Fthead%3E%0A++++%3Ctbody%3E%0A++++++++%3Ctr+class%3D%22tbody-tr%22%3E%0A++++++++++++%3Ctd+class%3D%22image%22%3E%0A++++++++++++++++%3Cimg+src%3D%22http%3A%2F%2Fwww.example.com%2Fimage.jpg%22%3E%0A++++++++++++%3C%2Ftd%3E%0A++++++++++++%3Ctd+class%3D%22title%22%3ETitle%0A++++++++++++%3C%2Ftd%3E%0A++++++++++++%3Ctd+class%3D%22date%22%3E12%2F16%2F2017%0A++++++++++++%3C%2Ftd%3E%0A++++++++%3C%2Ftr%3E%0A++++++++%3Ctr+class%3D%22tbody-tr%22%3E%0A++++++++++++%3Ctd+class%3D%22image%22%3E%0A++++++++++++++++%3Cimg+src%3D%22http%3A%2F%2Fwww.example.com%2Fimage.jpg%22%3E%0A++++++++++++%3C%2Ftd%3E%0A++++++++++++%3Ctd+class%3D%22title%22%3ETitle%0A++++++++++++%3C%2Ftd%3E%0A++++++++++++%3Ctd+class%3D%22date%22%3E12%2F16%2F2017%0A++++++++++++%3C%2Ftd%3E%0A++++++++%3C%2Ftr%3E%0A++++%3C%2Ftbody%3E%0A%3C%2Ftable%3E'
   31     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   32     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   33     7        ASSIGN_OBJ                                               !1, 'formatOutput'
          8        OP_DATA                                                  <true>
   35     9        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         10        SEND_VAL_EX                                              'tr'
         11        DO_FCALL                                      0  $10     
         12      > FE_RESET_R                                       $11     $10, ->31
         13    > > FE_FETCH_R                                               $11, !2, ->31
   36    14    >   INIT_METHOD_CALL                                         !1, 'createElement'
         15        SEND_VAL_EX                                              'td'
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !3, $12
   37    18        INIT_METHOD_CALL                                         !3, 'setAttribute'
         19        SEND_VAL_EX                                              'class'
         20        SEND_VAL_EX                                              'example'
         21        DO_FCALL                                      0          
   39    22        INIT_METHOD_CALL                                         !2, 'insertBefore'
         23        SEND_VAR_EX                                              !3
         24        FETCH_OBJ_R                                      ~15     !2, 'childNodes'
         25        INIT_METHOD_CALL                                         ~15, 'item'
         26        SEND_VAL_EX                                              3
         27        DO_FCALL                                      0  $16     
         28        SEND_VAR_NO_REF_EX                                       $16
         29        DO_FCALL                                      0          
   35    30      > JMP                                                      ->13
         31    >   FE_FREE                                                  $11
   42    32        INIT_METHOD_CALL                                         !1, 'saveHTML'
         33        DO_FCALL                                      0  $18     
         34        ECHO                                                     $18
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.21 ms | 1439 KiB | 13 Q