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 = 'demo www.google.bg'; preg_match_all($reg_exUrl, $text, $matches); $usedPatterns = array(); foreach($matches[0] as $pattern){ if(!array_key_exists($pattern, $usedPatterns)){ $usedPatterns[$pattern]=true; if(preg_match('%https://%',$pattern)) { $start = "https://"; }elseif(preg_match('%http://%',$pattern)){ $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 = 44
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 44
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 43
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/Oo3LN
function name:  (null)
number of ops:  47
compiled vars:  !0 = $reg_exUrl, !1 = $text, !2 = $matches, !3 = $usedPatterns, !4 = $pattern, !5 = $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'
    4     1        ASSIGN                                                   !1, 'demo+www.google.bg'
    5     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    6     7        ASSIGN                                                   !3, <array>
    7     8        FETCH_DIM_R                                      ~10     !2, 0
          9      > FE_RESET_R                                       $11     ~10, ->44
         10    > > FE_FETCH_R                                               $11, !4, ->44
    8    11    >   ARRAY_KEY_EXISTS                                 ~12     !4, !3
         12        BOOL_NOT                                         ~13     ~12
         13      > JMPZ                                                     ~13, ->43
    9    14    >   ASSIGN_DIM                                               !3, !4
         15        OP_DATA                                                  <true>
   10    16        INIT_FCALL                                               'preg_match'
         17        SEND_VAL                                                 '%25https%3A%2F%2F%25'
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                         $15     
         20      > JMPZ                                                     $15, ->23
   11    21    >   ASSIGN                                                   !5, 'https%3A%2F%2F'
         22      > JMP                                                      ->31
   12    23    >   INIT_FCALL                                               'preg_match'
         24        SEND_VAL                                                 '%25http%3A%2F%2F%25'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                         $17     
         27      > JMPZ                                                     $17, ->30
   13    28    >   ASSIGN                                                   !5, 'http%3A%2F%2F'
         29      > JMP                                                      ->31
   15    30    >   ASSIGN                                                   !5, 'http%3A%2F%2F'
   17    31    >   INIT_FCALL                                               'str_replace'
         32        SEND_VAR                                                 !4
         33        ROPE_INIT                                     6  ~21     '%3Ca+href%3D%27'
         34        ROPE_ADD                                      1  ~21     ~21, !5
         35        ROPE_ADD                                      2  ~21     ~21, !4
         36        ROPE_ADD                                      3  ~21     ~21, '%27+target%3D%27_blank%27%3E'
         37        ROPE_ADD                                      4  ~21     ~21, !4
         38        ROPE_END                                      5  ~20     ~21, '%3C%2Fa%3E+'
         39        SEND_VAL                                                 ~20
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                         $24     
         42        ASSIGN                                                   !1, $24
    7    43    > > JMP                                                      ->10
         44    >   FE_FREE                                                  $11
   20    45        ECHO                                                     !1
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.03 ms | 1400 KiB | 19 Q