3v4l.org

run code in 300+ PHP versions simultaneously
<?php $textbody = "<html> <ul> List item 1 List item 2 List item 3 </ul></html> "; $content = new DOMDocument; $content->loadHTML($textbody); //get DOMNodeList $ulList = $content->getElementsByTagName("ul"); //loop DOMNodeList to get nodes foreach ( $ulList as $ul ) { //get the lines between <ul> $lines = explode("\n",$ul->firstChild->wholeText); var_dump($lines); //work on each line foreach ($lines as $line) { $ul->appendChild($content->createElement('li',$line)); } } echo $textbody = $content->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 35
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 35
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 33
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 33
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/N18sm
function name:  (null)
number of ops:  41
compiled vars:  !0 = $textbody, !1 = $content, !2 = $ulList, !3 = $ul, !4 = $lines, !5 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%0A%3Cul%3E%0AList+item+1%0AList+item+2%0AList+item+3%0A%3C%2Ful%3E%3C%2Fhtml%3E%0A'
   10     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   11     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   13     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'ul'
          9        DO_FCALL                                      0  $11     
         10        ASSIGN                                                   !2, $11
   16    11      > FE_RESET_R                                       $13     !2, ->35
         12    > > FE_FETCH_R                                               $13, !3, ->35
   18    13    >   INIT_FCALL                                               'explode'
         14        SEND_VAL                                                 '%0A'
         15        FETCH_OBJ_R                                      ~14     !3, 'firstChild'
         16        FETCH_OBJ_R                                      ~15     ~14, 'wholeText'
         17        SEND_VAL                                                 ~15
         18        DO_ICALL                                         $16     
         19        ASSIGN                                                   !4, $16
   19    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                                 
   21    23      > FE_RESET_R                                       $19     !4, ->33
         24    > > FE_FETCH_R                                               $19, !5, ->33
   22    25    >   INIT_METHOD_CALL                                         !3, 'appendChild'
         26        INIT_METHOD_CALL                                         !1, 'createElement'
         27        SEND_VAL_EX                                              'li'
         28        SEND_VAR_EX                                              !5
         29        DO_FCALL                                      0  $20     
         30        SEND_VAR_NO_REF_EX                                       $20
         31        DO_FCALL                                      0          
   21    32      > JMP                                                      ->24
         33    >   FE_FREE                                                  $19
   16    34      > JMP                                                      ->12
         35    >   FE_FREE                                                  $13
   25    36        INIT_METHOD_CALL                                         !1, 'saveHTML'
         37        DO_FCALL                                      0  $22     
         38        ASSIGN                                           ~23     !0, $22
         39        ECHO                                                     ~23
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.59 ms | 1400 KiB | 17 Q