3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<HTML <h1>Or Any Other tags except img or nothing</h1> <span>stuff</span> <img src="{{media url=&quot;image_name.png&quot;}}" alt="image_test" /> <div>more stuff</div> <h1>Or Any Other tags except img or nothing</h1> HTML; function alterateContent(string $html, string $imageFileName, string $replacement): string { $imageFileName = preg_quote($imageFileName, '/'); return preg_replace("/<img\h+src=\"{{media url=&quot;{$imageFileName}&quot;}}\".*?\/>/", $replacement, $html); } echo alterateContent($html, 'image_name.png', '<b>Hi test</b>');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4gu1L
function name:  (null)
number of ops:  8
compiled vars:  !0 = $html
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Ch1%3EOr+Any+Other+tags+except+img+or+nothing%3C%2Fh1%3E%0A%3Cspan%3Estuff%3C%2Fspan%3E%0A%3Cimg+src%3D%22%7B%7Bmedia+url%3D%26quot%3Bimage_name.png%26quot%3B%7D%7D%22+alt%3D%22image_test%22+%2F%3E%0A%3Cdiv%3Emore+stuff%3C%2Fdiv%3E%0A%3Ch1%3EOr+Any+Other+tags+except+img+or+nothing%3C%2Fh1%3E'
   18     1        INIT_FCALL                                                   'alteratecontent'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     'image_name.png'
          4        SEND_VAL                                                     '%3Cb%3EHi+test%3C%2Fb%3E'
          5        DO_FCALL                                          0  $2      
          6        ECHO                                                         $2
          7      > RETURN                                                       1

Function alteratecontent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4gu1L
function name:  alterateContent
number of ops:  17
compiled vars:  !0 = $html, !1 = $imageFileName, !2 = $replacement
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   13     3        INIT_FCALL                                                   'preg_quote'
          4        SEND_VAR                                                     !1
          5        SEND_VAL                                                     '%2F'
          6        DO_ICALL                                             $3      
          7        ASSIGN                                                       !1, $3
   15     8        ROPE_INIT                                         3  ~6      '%2F%3Cimg%5Ch%2Bsrc%3D%22%7B%7Bmedia+url%3D%26quot%3B'
          9        ROPE_ADD                                          1  ~6      ~6, !1
         10        ROPE_END                                          2  ~5      ~6, '%26quot%3B%7D%7D%22.%2A%3F%5C%2F%3E%2F'
         11        FRAMELESS_ICALL_3                preg_replace        ~8      ~5, !2
         12        OP_DATA                                                      !0
         13        VERIFY_RETURN_TYPE                                           ~8
         14      > RETURN                                                       ~8
   16    15*       VERIFY_RETURN_TYPE                                           
         16*     > RETURN                                                       null

End of function alteratecontent

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.99 ms | 2131 KiB | 15 Q