3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "demo link edno www.abv.bg link 2 http://abv123.bg/"; $reg_exUrl = "/((http|https|ftp|ftps)\:\/\/|(www)\.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; preg_match_all($reg_exUrl, $text, $matches); $usedPatterns = array(); foreach($matches[0] as $pattern){ if(!array_key_exists($pattern, $usedPatterns)){ $usedPatterns[$pattern]=true; $text = str_replace ($pattern, "<a href='{$pattern}' target='_blank'>{$pattern}</a> ", $text); } } echo $text;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 28
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 27
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 27
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/WepRX
function name:  (null)
number of ops:  31
compiled vars:  !0 = $text, !1 = $reg_exUrl, !2 = $matches, !3 = $usedPatterns, !4 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'demo+link+edno+www.abv.bg+link+2+http%3A%2F%2Fabv123.bg%2F'
    3     1        ASSIGN                                                   !1, '%2F%28%28http%7Chttps%7Cftp%7Cftps%29%5C%3A%5C%2F%5C%2F%7C%28www%29%5C.%29%5Ba-zA-Z0-9%5C-%5C.%5D%2B%5C.%5Ba-zA-Z%5D%7B2%2C3%7D%28%5C%2F%5CS%2A%29%3F%2F'
    4     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    5     7        ASSIGN                                                   !3, <array>
    6     8        FETCH_DIM_R                                      ~9      !2, 0
          9      > FE_RESET_R                                       $10     ~9, ->28
         10    > > FE_FETCH_R                                               $10, !4, ->28
    7    11    >   ARRAY_KEY_EXISTS                                 ~11     !4, !3
         12        BOOL_NOT                                         ~12     ~11
         13      > JMPZ                                                     ~12, ->27
    8    14    >   ASSIGN_DIM                                               !3, !4
         15        OP_DATA                                                  <true>
    9    16        INIT_FCALL                                               'str_replace'
         17        SEND_VAR                                                 !4
         18        ROPE_INIT                                     5  ~15     '%3Ca+href%3D%27'
         19        ROPE_ADD                                      1  ~15     ~15, !4
         20        ROPE_ADD                                      2  ~15     ~15, '%27+target%3D%27_blank%27%3E'
         21        ROPE_ADD                                      3  ~15     ~15, !4
         22        ROPE_END                                      4  ~14     ~15, '%3C%2Fa%3E+'
         23        SEND_VAL                                                 ~14
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $18     
         26        ASSIGN                                                   !0, $18
    6    27    > > JMP                                                      ->10
         28    >   FE_FREE                                                  $10
   12    29        ECHO                                                     !0
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.54 ms | 1396 KiB | 17 Q