3v4l.org

run code in 300+ PHP versions simultaneously
<?php $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 '; $dom = new DOMDocument; $dom->loadHTML($html); $replacement = 'FOO'; foreach ($dom->getElementsByTagName('a') as $node) { $href = $node->getAttribute('href'); $node->setAttribute('href', preg_replace('/([a-z])?\d{5}/i', $replacement, $href)); } $html = preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $dom->saveHTML()); echo $html;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/OjnCl
function name:  (null)
number of ops:  38
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, '%0Asome+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%0A'
    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        DO_FCALL                                      0          
   10     7        ASSIGN                                                   !2, 'FOO'
   12     8        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          9        SEND_VAL_EX                                              'a'
         10        DO_FCALL                                      0  $11     
         11      > FE_RESET_R                                       $12     $11, ->27
         12    > > FE_FETCH_R                                               $12, !3, ->27
   13    13    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         14        SEND_VAL_EX                                              'href'
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !4, $13
   14    17        INIT_METHOD_CALL                                         !3, 'setAttribute'
         18        SEND_VAL_EX                                              'href'
         19        INIT_FCALL                                               'preg_replace'
         20        SEND_VAL                                                 '%2F%28%5Ba-z%5D%29%3F%5Cd%7B5%7D%2Fi'
         21        SEND_VAR                                                 !2
         22        SEND_VAR                                                 !4
         23        DO_ICALL                                         $15     
         24        SEND_VAR_NO_REF_EX                                       $15
         25        DO_FCALL                                      0          
   12    26      > JMP                                                      ->12
         27    >   FE_FREE                                                  $12
   17    28        INIT_FCALL                                               'preg_replace'
         29        SEND_VAL                                                 '%7E%3C%28%3F%3A%21DOCTYPE%7C%2F%3F%28%3F%3Ahtml%7Cbody%29%29%5B%5E%3E%5D%2A%3E%5Cs%2A%7Ei'
         30        SEND_VAL                                                 ''
         31        INIT_METHOD_CALL                                         !1, 'saveHTML'
         32        DO_FCALL                                      0  $17     
         33        SEND_VAR                                                 $17
         34        DO_ICALL                                         $18     
         35        ASSIGN                                                   !0, $18
   19    36        ECHO                                                     !0
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.66 ms | 1392 KiB | 15 Q