3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <!DOCTYPE HTML> <html> <body> <p><span class="unwrap_me">Lorem</span><span class="unwrap_me">ipsum</span><span class="unwrap_me">dolor</span></p> </body> </html> HTML; $dom = new DOMDocument(); $dom->loadHTML($html); $spans = iterator_to_array($dom->getElementsByTagName('span')->getIterator()); foreach ($spans as $span) { if ('unwrap_me' === $span->getAttribute('class')) { $span->replaceWith(...$span->childNodes); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/KjJgQ
function name:  (null)
number of ops:  31
compiled vars:  !0 = $html, !1 = $dom, !2 = $spans, !3 = $span
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%21DOCTYPE+HTML%3E%0A%3Chtml%3E%0A%3Cbody%3E%0A++++%3Cp%3E%3Cspan+class%3D%22unwrap_me%22%3ELorem%3C%2Fspan%3E%3Cspan+class%3D%22unwrap_me%22%3Eipsum%3C%2Fspan%3E%3Cspan+class%3D%22unwrap_me%22%3Edolor%3C%2Fspan%3E%3C%2Fp%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   11     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   12     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   14     7        INIT_FCALL                                               'iterator_to_array'
          8        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          9        SEND_VAL_EX                                              'span'
         10        DO_FCALL                                      0  $9      
         11        INIT_METHOD_CALL                                         $9, 'getIterator'
         12        DO_FCALL                                      0  $10     
         13        SEND_VAR                                                 $10
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !2, $11
   15    16      > FE_RESET_R                                       $13     !2, ->29
         17    > > FE_FETCH_R                                               $13, !3, ->29
   16    18    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         19        SEND_VAL_EX                                              'class'
         20        DO_FCALL                                      0  $14     
         21        IS_IDENTICAL                                             $14, 'unwrap_me'
         22      > JMPZ                                                     ~15, ->28
   17    23    >   INIT_METHOD_CALL                                         !3, 'replaceWith'
         24        FETCH_OBJ_R                                      ~16     !3, 'childNodes'
         25        SEND_UNPACK                                              ~16
         26        CHECK_UNDEF_ARGS                                         
         27        DO_FCALL                                      1          
   15    28    > > JMP                                                      ->17
         29    >   FE_FREE                                                  $13
   19    30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.1 ms | 1001 KiB | 14 Q