3v4l.org

run code in 300+ PHP versions simultaneously
<?php $textbody = " <ul> List item 1 List item 2 List item 3 </ul> "; $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); //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 = 32
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 32
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 30
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/iTLkq
function name:  (null)
number of ops:  38
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, '%0A%3Cul%3E%0AList+item+1%0AList+item+2%0AList+item+3%0A%3C%2Ful%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, ->32
         12    > > FE_FETCH_R                                               $13, !3, ->32
   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
   20    20      > FE_RESET_R                                       $18     !4, ->30
         21    > > FE_FETCH_R                                               $18, !5, ->30
   21    22    >   INIT_METHOD_CALL                                         !3, 'appendChild'
         23        INIT_METHOD_CALL                                         !1, 'createElement'
         24        SEND_VAL_EX                                              'li'
         25        SEND_VAR_EX                                              !5
         26        DO_FCALL                                      0  $19     
         27        SEND_VAR_NO_REF_EX                                       $19
         28        DO_FCALL                                      0          
   20    29      > JMP                                                      ->21
         30    >   FE_FREE                                                  $18
   16    31      > JMP                                                      ->12
         32    >   FE_FREE                                                  $13
   24    33        INIT_METHOD_CALL                                         !1, 'saveHTML'
         34        DO_FCALL                                      0  $21     
         35        ASSIGN                                           ~22     !0, $21
         36        ECHO                                                     ~22
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.61 ms | 1392 KiB | 15 Q