3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<HTML <a class="dessert" href="http://mywebsite.com/chocolate.php" title="Try out our new chocolate">chocolate</a> <a class="dessert" href="http://mywebsite.com/chocolate.php" title="Try out our new chocolate cookies">chocolate</a> <a class="dessert" href="http://mywebsite.com/chocolate.php" title="Try out our new chocolate vanilla cookies">chocolate</a> HTML; $doc = new DomDocument(); $fragment = $doc->createDocumentFragment(); $fragment->appendXML($html); $doc->appendChild($fragment); $nodes = $doc->getElementsByTagName('a'); foreach ($nodes as $node) { $node->setAttribute( "title", preg_replace("~\bchocolate(?:(?:\hvanilla)?\hcookies)?\b~", "chocolate chip cookies", $node->getAttribute("title") ) ); } echo $doc->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/QhXOv
function name:  (null)
number of ops:  34
compiled vars:  !0 = $html, !1 = $doc, !2 = $fragment, !3 = $nodes, !4 = $node
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Ca+class%3D%22dessert%22+href%3D%22http%3A%2F%2Fmywebsite.com%2Fchocolate.php%22+title%3D%22Try+out+our+new+chocolate%22%3Echocolate%3C%2Fa%3E%0A%3Ca+class%3D%22dessert%22+href%3D%22http%3A%2F%2Fmywebsite.com%2Fchocolate.php%22+title%3D%22Try+out+our+new+chocolate+cookies%22%3Echocolate%3C%2Fa%3E%0A%3Ca+class%3D%22dessert%22+href%3D%22http%3A%2F%2Fmywebsite.com%2Fchocolate.php%22+title%3D%22Try+out+our+new+chocolate+vanilla+cookies%22%3Echocolate%3C%2Fa%3E'
    9     1        NEW                                                  $6      'DomDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $6
   10     4        INIT_METHOD_CALL                                             !1, 'createDocumentFragment'
          5        DO_FCALL                                          0  $9      
          6        ASSIGN                                                       !2, $9
   11     7        INIT_METHOD_CALL                                             !2, 'appendXML'
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0          
   12    10        INIT_METHOD_CALL                                             !1, 'appendChild'
         11        SEND_VAR_EX                                                  !2
         12        DO_FCALL                                          0          
   13    13        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
         14        SEND_VAL_EX                                                  'a'
         15        DO_FCALL                                          0  $13     
         16        ASSIGN                                                       !3, $13
   15    17      > FE_RESET_R                                           $15     !3, ->29
         18    > > FE_FETCH_R                                                   $15, !4, ->29
   16    19    >   INIT_METHOD_CALL                                             !4, 'setAttribute'
   17    20        SEND_VAL_EX                                                  'title'
   18    21        INIT_METHOD_CALL                                             !4, 'getAttribute'
         22        SEND_VAL_EX                                                  'title'
         23        DO_FCALL                                          0  $16     
         24        FRAMELESS_ICALL_3                preg_replace        ~17     '%7E%5Cbchocolate%28%3F%3A%28%3F%3A%5Chvanilla%29%3F%5Chcookies%29%3F%5Cb%7E', 'chocolate+chip+cookies'
         25        OP_DATA                                                      $16
         26        SEND_VAL_EX                                                  ~17
   16    27        DO_FCALL                                          0          
   15    28      > JMP                                                          ->18
         29    >   FE_FREE                                                      $15
   22    30        INIT_METHOD_CALL                                             !1, 'saveHTML'
         31        DO_FCALL                                          0  $19     
         32        ECHO                                                         $19
         33      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
238.36 ms | 2186 KiB | 13 Q