3v4l.org

run code in 300+ PHP versions simultaneously
<div class="first-slide"></div> <div class="container"></div> <?php $htmlString = '<html>...</html>';//either generated, or loaded from a file $dom = new DOMDocument; $dom->loadHTML($htmlString);//or loadHTMLFile $divs = $dom->getElementsByTagName('div'); foreach($divs as $div) { if ($div->hasAttribute('class') && strstr($div->getAttribute('class'), 'first-slide')) { //$div ~= <div class='one-two-three'> $div->appendChild( '<div class="wrapper"></div>');//check the docs to see what you can do } } ?>
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
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 30
Branch analysis from position: 26
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/sjKDB
function name:  (null)
number of ops:  33
compiled vars:  !0 = $htmlString, !1 = $dom, !2 = $divs, !3 = $div
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3Cdiv+class%3D%22first-slide%22%3E%3C%2Fdiv%3E%0A%3Cdiv+class%3D%22container%22%3E%3C%2Fdiv%3E%0A%0A'
    5     1        ASSIGN                                                   !0, '%3Chtml%3E...%3C%2Fhtml%3E'
    6     2        NEW                                              $5      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $5
    7     5        INIT_METHOD_CALL                                         !1, 'loadHTML'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
    8     8        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          9        SEND_VAL_EX                                              'div'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
    9    12      > FE_RESET_R                                       $11     !2, ->31
         13    > > FE_FETCH_R                                               $11, !3, ->31
   11    14    >   INIT_METHOD_CALL                                         !3, 'hasAttribute'
         15        SEND_VAL_EX                                              'class'
         16        DO_FCALL                                      0  $12     
         17      > JMPZ_EX                                          ~13     $12, ->26
         18    >   INIT_FCALL                                               'strstr'
         19        INIT_METHOD_CALL                                         !3, 'getAttribute'
         20        SEND_VAL_EX                                              'class'
         21        DO_FCALL                                      0  $14     
         22        SEND_VAR                                                 $14
         23        SEND_VAL                                                 'first-slide'
         24        DO_ICALL                                         $15     
         25        BOOL                                             ~13     $15
         26    > > JMPZ                                                     ~13, ->30
   14    27    >   INIT_METHOD_CALL                                         !3, 'appendChild'
         28        SEND_VAL_EX                                              '%3Cdiv+class%3D%22wrapper%22%3E%3C%2Fdiv%3E'
         29        DO_FCALL                                      0          
    9    30    > > JMP                                                      ->13
         31    >   FE_FREE                                                  $11
   16    32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.65 ms | 1396 KiB | 15 Q