3v4l.org

run code in 300+ PHP versions simultaneously
<?php $reg_exUrl = "/((http|https)\:\/\/|(www)\.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; $text = 'some text http://google.bg/'; preg_match_all($reg_exUrl, $text, $matches); $usedPatterns = array(); foreach($matches[0] as $pattern){ if(!array_key_exists($pattern, $usedPatterns)) { echo $pattern; $usedPatterns[$pattern]=true; if(preg_match('%https://%',$pattern)) { $patttern = str_replace('https://', ''); $start = "https://"; } elseif(preg_match('%http://%',$pattern)) { $pattern = str_replace('http://', ''); $start = "http://"; } else { $start = "http://"; } $text = str_replace ($pattern, "<a href='{$start}{$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 = 55
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 55
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 54
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 41
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 54
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
filename:       /in/HdDYZ
function name:  (null)
number of ops:  58
compiled vars:  !0 = $reg_exUrl, !1 = $text, !2 = $matches, !3 = $usedPatterns, !4 = $pattern, !5 = $patttern, !6 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%2F%28%28http%7Chttps%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'
    3     1        ASSIGN                                                   !1, 'some+text+http%3A%2F%2Fgoogle.bg%2F'
    4     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    5     7        ASSIGN                                                   !3, <array>
    6     8        FETCH_DIM_R                                      ~11     !2, 0
          9      > FE_RESET_R                                       $12     ~11, ->55
         10    > > FE_FETCH_R                                               $12, !4, ->55
    7    11    >   ARRAY_KEY_EXISTS                                 ~13     !4, !3
         12        BOOL_NOT                                         ~14     ~13
         13      > JMPZ                                                     ~14, ->54
    9    14    >   ECHO                                                     !4
   10    15        ASSIGN_DIM                                               !3, !4
         16        OP_DATA                                                  <true>
   11    17        INIT_FCALL                                               'preg_match'
         18        SEND_VAL                                                 '%25https%3A%2F%2F%25'
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                         $16     
         21      > JMPZ                                                     $16, ->29
   13    22    >   INIT_FCALL                                               'str_replace'
         23        SEND_VAL                                                 'https%3A%2F%2F'
         24        SEND_VAL                                                 ''
         25        DO_ICALL                                         $17     
         26        ASSIGN                                                   !5, $17
   14    27        ASSIGN                                                   !6, 'https%3A%2F%2F'
         28      > JMP                                                      ->42
   16    29    >   INIT_FCALL                                               'preg_match'
         30        SEND_VAL                                                 '%25http%3A%2F%2F%25'
         31        SEND_VAR                                                 !4
         32        DO_ICALL                                         $20     
         33      > JMPZ                                                     $20, ->41
   18    34    >   INIT_FCALL                                               'str_replace'
         35        SEND_VAL                                                 'http%3A%2F%2F'
         36        SEND_VAL                                                 ''
         37        DO_ICALL                                         $21     
         38        ASSIGN                                                   !4, $21
   19    39        ASSIGN                                                   !6, 'http%3A%2F%2F'
         40      > JMP                                                      ->42
   23    41    >   ASSIGN                                                   !6, 'http%3A%2F%2F'
   26    42    >   INIT_FCALL                                               'str_replace'
         43        SEND_VAR                                                 !4
         44        ROPE_INIT                                     6  ~26     '%3Ca+href%3D%27'
         45        ROPE_ADD                                      1  ~26     ~26, !6
         46        ROPE_ADD                                      2  ~26     ~26, !4
         47        ROPE_ADD                                      3  ~26     ~26, '%27+target%3D%27_blank%27%3E'
         48        ROPE_ADD                                      4  ~26     ~26, !4
         49        ROPE_END                                      5  ~25     ~26, '%3C%2Fa%3E+'
         50        SEND_VAL                                                 ~25
         51        SEND_VAR                                                 !1
         52        DO_ICALL                                         $29     
         53        ASSIGN                                                   !1, $29
    6    54    > > JMP                                                      ->10
         55    >   FE_FREE                                                  $12
   29    56        ECHO                                                     !1
         57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.18 ms | 1400 KiB | 19 Q