3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "{download='text for button'} HAHA! {download='test'}"; $download = '<a class="button">Download</a>'; $search = "{download}"; if (contains($string,$search)) $string=str_ireplace($search,$download,$string); preg_match_all("/{download='(.*?)'}/", $string, $matches, PREG_SET_ORDER); foreach ($matches as $val) { $string = str_replace("{download='" . $val[1] . "'}", "<a class=\"button\">" . $val[1] . "</a>", $string); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 35
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 35
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 14
filename:       /in/95p1X
function name:  (null)
number of ops:  37
compiled vars:  !0 = $string, !1 = $download, !2 = $search, !3 = $matches, !4 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7Bdownload%3D%27text+for+button%27%7D+HAHA%21+%7Bdownload%3D%27test%27%7D'
    5     1        ASSIGN                                                   !1, '%3Ca+class%3D%22button%22%3EDownload%3C%2Fa%3E'
    6     2        ASSIGN                                                   !2, '%7Bdownload%7D'
    7     3        INIT_FCALL_BY_NAME                                       'contains'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !2
          6        DO_FCALL                                      0  $8      
          7      > JMPZ                                                     $8, ->14
    8     8    >   INIT_FCALL                                               'str_ireplace'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !0, $9
   10    14    >   INIT_FCALL                                               'preg_match_all'
         15        SEND_VAL                                                 '%2F%7Bdownload%3D%27%28.%2A%3F%29%27%7D%2F'
         16        SEND_VAR                                                 !0
         17        SEND_REF                                                 !3
         18        SEND_VAL                                                 2
         19        DO_ICALL                                                 
   12    20      > FE_RESET_R                                       $12     !3, ->35
         21    > > FE_FETCH_R                                               $12, !4, ->35
   13    22    >   INIT_FCALL                                               'str_replace'
         23        FETCH_DIM_R                                      ~13     !4, 1
         24        CONCAT                                           ~14     '%7Bdownload%3D%27', ~13
         25        CONCAT                                           ~15     ~14, '%27%7D'
         26        SEND_VAL                                                 ~15
         27        FETCH_DIM_R                                      ~16     !4, 1
         28        CONCAT                                           ~17     '%3Ca+class%3D%22button%22%3E', ~16
         29        CONCAT                                           ~18     ~17, '%3C%2Fa%3E'
         30        SEND_VAL                                                 ~18
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $19     
         33        ASSIGN                                                   !0, $19
   12    34      > JMP                                                      ->21
         35    >   FE_FREE                                                  $12
   14    36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.58 ms | 1400 KiB | 19 Q