3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div style='font-family: "Times New Roman", Georgia, serif; background-color: #ffffff; '> <p>Some text <span class="ohyeah" style="font-weight: bold; color: #ff6633 !important; border: solid 1px grey;"> Monkeywrench: style="padding: 3px;" </span> & <strong style="text-decoration: underline; ">Underlined</strong> </p> <h1 style="margin: 1px 2px 3px 4px;">Heading</h1> <span style="background-image: url('images/not_a_hexcode_ffffff.png'); ">Text</span> </div> HTML; $dom = new DOMDocument; libxml_use_internal_errors(true); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); foreach ($dom->getElementsByTagName('*') as $node) { $style = $node->getAttribute('style'); if ($style) { $patterns = ['~[:;,]\K\s+~', '~#\K([\da-f])\1([\da-f])\2([\da-f])\3~i']; $replaces = ['', '\1\2\3']; $node->setAttribute('style', preg_replace($patterns, $replaces, $style)); } } $html = $dom->saveHtml(); echo $html;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 33
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 32
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 32
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/ZUrne
function name:  (null)
number of ops:  39
compiled vars:  !0 = $html, !1 = $dom, !2 = $node, !3 = $style, !4 = $patterns, !5 = $replaces
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cdiv+style%3D%27font-family%3A+%22Times+New+Roman%22%2C+Georgia%2C+serif%3B+background-color%3A+%23ffffff%3B+%27%3E%0A++%3Cp%3ESome+text+%0A++++%3Cspan+class%3D%22ohyeah%22+style%3D%22font-weight%3A+bold%3B+color%3A+%23ff6633+%21important%3B+border%3A+solid+1px+grey%3B%22%3E%0A++++++Monkeywrench%3A+style%3D%22padding%3A+3px%3B%22%0A++++%3C%2Fspan%3E%0A++++%26%0A++++%3Cstrong+style%3D%22text-decoration%3A+underline%3B+%22%3EUnderlined%3C%2Fstrong%3E%0A++%3C%2Fp%3E%0A++%3Ch1+style%3D%22margin%3A+1px+2px+3px+4px%3B%22%3EHeading%3C%2Fh1%3E%0A++%3Cspan+style%3D%22background-image%3A+++++url%28%27images%2Fnot_a_hexcode_ffffff.png%27%29%3B++++%22%3EText%3C%2Fspan%3E%0A%3C%2Fdiv%3E'
   16     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   17     4        INIT_FCALL                                               'libxml_use_internal_errors'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                                 
   18     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAL_EX                                              8196
         10        DO_FCALL                                      0          
   19    11        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         12        SEND_VAL_EX                                              '%2A'
         13        DO_FCALL                                      0  $12     
         14      > FE_RESET_R                                       $13     $12, ->33
         15    > > FE_FETCH_R                                               $13, !2, ->33
   20    16    >   INIT_METHOD_CALL                                         !2, 'getAttribute'
         17        SEND_VAL_EX                                              'style'
         18        DO_FCALL                                      0  $14     
         19        ASSIGN                                                   !3, $14
   21    20      > JMPZ                                                     !3, ->32
   22    21    >   ASSIGN                                                   !4, <array>
   23    22        ASSIGN                                                   !5, <array>
   24    23        INIT_METHOD_CALL                                         !2, 'setAttribute'
         24        SEND_VAL_EX                                              'style'
         25        INIT_FCALL                                               'preg_replace'
         26        SEND_VAR                                                 !4
         27        SEND_VAR                                                 !5
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $18     
         30        SEND_VAR_NO_REF_EX                                       $18
         31        DO_FCALL                                      0          
   19    32    > > JMP                                                      ->15
         33    >   FE_FREE                                                  $13
   27    34        INIT_METHOD_CALL                                         !1, 'saveHtml'
         35        DO_FCALL                                      0  $20     
         36        ASSIGN                                                   !0, $20
   28    37        ECHO                                                     !0
   29    38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.17 ms | 1016 KiB | 15 Q