3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re ='/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/im'; $str = 'Test text http://hello-world.com Test text http://google.com/file.jpg?google=1 Test text https://hell.o.wor.ld/test?qwe=qwe Test text text text http://test.test/test hello all how are you I hope you all are fine '; $utmUrl = "utm_source=source&utm_medium=email&utm_campaign=mycamp"; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); foreach ($matches as $match) $str = preg_replace('%' . $match[0] . '%', $match[0] . (strpos($match[0], '?') !== false ? '&' : '?') . $utmUrl, $str); var_dump($str);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 35
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 35
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/EPf8t
function name:  (null)
number of ops:  40
compiled vars:  !0 = $re, !1 = $str, !2 = $utmUrl, !3 = $matches, !4 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%28%3F%3A%28%3F%3Ahttps%3F%7Cftp%7Cfile%29%3A%5C%2F%5C%2F%7Cwww%5C.%7Cftp%5C.%29%28%3F%3A%5C%28%5B-A-Z0-9%2B%26%40%23%5C%2F%25%3D%7E_%7C%24%3F%21%3A%2C.%5D%2A%5C%29%7C%5B-A-Z0-9%2B%26%40%23%5C%2F%25%3D%7E_%7C%24%3F%21%3A%2C.%5D%29%2A%28%3F%3A%5C%28%5B-A-Z0-9%2B%26%40%23%5C%2F%25%3D%7E_%7C%24%3F%21%3A%2C.%5D%2A%5C%29%7C%5BA-Z0-9%2B%26%40%23%5C%2F%25%3D%7E_%7C%24%5D%29%2Fim'
    4     1        ASSIGN                                                   !1, 'Test+text+http%3A%2F%2Fhello-world.com+Test+text++http%3A%2F%2Fgoogle.com%2Ffile.jpg%3Fgoogle%3D1+Test+text+https%3A%2F%2Fhell.o.wor.ld%2Ftest%3Fqwe%3Dqwe+Test+text+text+text+http%3A%2F%2Ftest.test%2Ftest+hello+all+how+are+you+I+hope+you+all+are+fine+'
    5     2        ASSIGN                                                   !2, 'utm_source%3Dsource%26utm_medium%3Demail%26utm_campaign%3Dmycamp'
    6     3        INIT_FCALL                                               'preg_match_all'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_REF                                                 !3
          7        SEND_VAL                                                 2
          8        SEND_VAL                                                 0
          9        DO_ICALL                                                 
    7    10      > FE_RESET_R                                       $9      !3, ->35
         11    > > FE_FETCH_R                                               $9, !4, ->35
    8    12    >   INIT_FCALL                                               'preg_replace'
         13        FETCH_DIM_R                                      ~10     !4, 0
         14        CONCAT                                           ~11     '%25', ~10
         15        CONCAT                                           ~12     ~11, '%25'
         16        SEND_VAL                                                 ~12
         17        FETCH_DIM_R                                      ~13     !4, 0
         18        INIT_FCALL                                               'strpos'
         19        FETCH_DIM_R                                      ~14     !4, 0
         20        SEND_VAL                                                 ~14
         21        SEND_VAL                                                 '%3F'
         22        DO_ICALL                                         $15     
         23        TYPE_CHECK                                  1018          $15
         24      > JMPZ                                                     ~16, ->27
         25    >   QM_ASSIGN                                        ~17     '%26'
         26      > JMP                                                      ->28
         27    >   QM_ASSIGN                                        ~17     '%3F'
         28    >   CONCAT                                           ~18     ~13, ~17
         29        CONCAT                                           ~19     ~18, !2
         30        SEND_VAL                                                 ~19
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                         $20     
         33        ASSIGN                                                   !1, $20
    7    34      > JMP                                                      ->11
         35    >   FE_FREE                                                  $9
    9    36        INIT_FCALL                                               'var_dump'
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.48 ms | 1400 KiB | 21 Q