3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<img src="data:image/png;base64,iVBORw0..="><img src="data:image/png;base64,iVBORw1..=">'; function deleteBase64_andReplace($start, $end, $replacement, $string) { $count = 0; $pattern = '|' . preg_quote($start, '|') . '(.*?)' . preg_quote($end, '|') . '|s'; while (strpos($string, $start) !== false) { return preg_replace_callback($pattern, function($m) use ($replacement, &$count) { return $replacement . ++$count;}, $string); } } $replacement = "image"; $stringResult= deleteBase64_andReplace("data:", "=", $replacement, $string); echo $stringResult;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lHPoI
function name:  (null)
number of ops:  11
compiled vars:  !0 = $string, !1 = $replacement, !2 = $stringResult
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cimg+src%3D%22data%3Aimage%2Fpng%3Bbase64%2CiVBORw0..%3D%22%3E%3Cimg+src%3D%22data%3Aimage%2Fpng%3Bbase64%2CiVBORw1..%3D%22%3E'
   13     1        ASSIGN                                                   !1, 'image'
   14     2        INIT_FCALL                                               'deletebase64_andreplace'
          3        SEND_VAL                                                 'data%3A'
          4        SEND_VAL                                                 '%3D'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $5      
          8        ASSIGN                                                   !2, $5
   15     9        ECHO                                                     !2
   16    10      > RETURN                                                   1

Function deletebase64_andreplace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 19
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lHPoI
function name:  deleteBase64_andReplace
number of ops:  35
compiled vars:  !0 = $start, !1 = $end, !2 = $replacement, !3 = $string, !4 = $count, !5 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    6     4        ASSIGN                                                   !4, 0
    7     5        INIT_FCALL                                               'preg_quote'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 '%7C'
          8        DO_ICALL                                         $7      
          9        CONCAT                                           ~8      '%7C', $7
         10        CONCAT                                           ~9      ~8, '%28.%2A%3F%29'
         11        INIT_FCALL                                               'preg_quote'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 '%7C'
         14        DO_ICALL                                         $10     
         15        CONCAT                                           ~11     ~9, $10
         16        CONCAT                                           ~12     ~11, '%7Cs'
         17        ASSIGN                                                   !5, ~12
    8    18      > JMP                                                      ->28
    9    19    >   INIT_FCALL                                               'preg_replace_callback'
         20        SEND_VAR                                                 !5
         21        DECLARE_LAMBDA_FUNCTION                          ~14     [0]
         22        BIND_LEXICAL                                             ~14, !2
         23        BIND_LEXICAL                                             ~14, !4
   10    24        SEND_VAL                                                 ~14
         25        SEND_VAR                                                 !3
    9    26        DO_ICALL                                         $15     
   10    27      > RETURN                                                   $15
    8    28    >   INIT_FCALL                                               'strpos'
         29        SEND_VAR                                                 !3
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $16     
         32        TYPE_CHECK                                  1018          $16
         33      > JMPNZ                                                    ~17, ->19
   12    34    > > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lHPoI
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $m, !1 = $replacement, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   10     3        PRE_INC                                          ~3      !2
          4        CONCAT                                           ~4      !1, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 0

End of function deletebase64_andreplace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
265.71 ms | 1020 KiB | 17 Q