3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' some content here <a href="/uploads/2014/04/Draft-99990-Details.doc">Draft 99995 Details</a> more text here <a href="/uploads/2014/04/01090-vs-G01010-series.pdf">01095 vs G01015 Series</a> and some final text here HTML; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); $replacement = 'FOO'; foreach ($dom->getElementsByTagName('a') as $node) { $href = $node->getAttribute('href'); $node->setAttribute('href', preg_replace('/([a-z])?\d{5}/i', $replacement, $href)); } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 28
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 28
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/mhuGh
function name:  (null)
number of ops:  33
compiled vars:  !0 = $html, !1 = $dom, !2 = $replacement, !3 = $node, !4 = $href
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'some+content+here+%3Ca+href%3D%22%2Fuploads%2F2014%2F04%2FDraft-99990-Details.doc%22%3EDraft+99995+Details%3C%2Fa%3E+more+text+here+%3Ca+href%3D%22%2Fuploads%2F2014%2F04%2F01090-vs-G01010-series.pdf%22%3E01095+vs+G01015+Series%3C%2Fa%3E+and+some+final+text+here'
    7     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
    8     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
   10     8        ASSIGN                                                   !2, 'FOO'
   12     9        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         10        SEND_VAL_EX                                              'a'
         11        DO_FCALL                                      0  $11     
         12      > FE_RESET_R                                       $12     $11, ->28
         13    > > FE_FETCH_R                                               $12, !3, ->28
   13    14    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         15        SEND_VAL_EX                                              'href'
         16        DO_FCALL                                      0  $13     
         17        ASSIGN                                                   !4, $13
   14    18        INIT_METHOD_CALL                                         !3, 'setAttribute'
         19        SEND_VAL_EX                                              'href'
         20        INIT_FCALL                                               'preg_replace'
         21        SEND_VAL                                                 '%2F%28%5Ba-z%5D%29%3F%5Cd%7B5%7D%2Fi'
         22        SEND_VAR                                                 !2
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                         $15     
         25        SEND_VAR_NO_REF_EX                                       $15
         26        DO_FCALL                                      0          
   12    27      > JMP                                                      ->13
         28    >   FE_FREE                                                  $12
   17    29        INIT_METHOD_CALL                                         !1, 'saveHTML'
         30        DO_FCALL                                      0  $17     
         31        ECHO                                                     $17
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.91 ms | 1396 KiB | 15 Q