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://mybreaktrip.cs.bsbm.eu/trip/view_bids/vienna-tripbsbm-ltd'; 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) && !preg_match('%http://%',$pattern)) { $start = "http://"; } if(strlen($pattern) > 18) { $parseurl = parse_url($pattern); $pattern_short = $parseurl['host'].substr($parseurl['path'], 0, 5).'...'.substr($parseurl['path'], -7); } $text = str_replace($pattern, "<a href='".(isset($start) ? $start : '')."{$pattern}' target='_blank'>".(isset($pattern_short) ? $pattern_short : $pattern)."</a> ", $text); } } echo $text;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 76
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 76
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 75
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 53
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 59
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 68
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 68
Branch analysis from position: 66
Branch analysis from position: 68
Branch analysis from position: 53
Branch analysis from position: 30
Branch analysis from position: 28
Branch analysis from position: 75
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
filename:       /in/doEgF
function name:  (null)
number of ops:  79
compiled vars:  !0 = $reg_exUrl, !1 = $text, !2 = $matches, !3 = $usedPatterns, !4 = $pattern, !5 = $start, !6 = $parseurl, !7 = $pattern_short
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%2Fmybreaktrip.cs.bsbm.eu%2Ftrip%2Fview_bids%2Fvienna-tripbsbm-ltd'
    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                                      ~12     !2, 0
          9      > FE_RESET_R                                       $13     ~12, ->76
         10    > > FE_FETCH_R                                               $13, !4, ->76
    7    11    >   ARRAY_KEY_EXISTS                                 ~14     !4, !3
         12        BOOL_NOT                                         ~15     ~14
         13      > JMPZ                                                     ~15, ->75
    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                                         $17     
         20        BOOL_NOT                                         ~18     $17
         21      > JMPZ_EX                                          ~18     ~18, ->28
         22    >   INIT_FCALL                                               'preg_match'
         23        SEND_VAL                                                 '%25http%3A%2F%2F%25'
         24        SEND_VAR                                                 !4
         25        DO_ICALL                                         $19     
         26        BOOL_NOT                                         ~20     $19
         27        BOOL                                             ~18     ~20
         28    > > JMPZ                                                     ~18, ->30
   12    29    >   ASSIGN                                                   !5, 'http%3A%2F%2F'
   14    30    >   STRLEN                                           ~22     !4
         31        IS_SMALLER                                               18, ~22
         32      > JMPZ                                                     ~23, ->53
   16    33    >   INIT_FCALL                                               'parse_url'
         34        SEND_VAR                                                 !4
         35        DO_ICALL                                         $24     
         36        ASSIGN                                                   !6, $24
   17    37        FETCH_DIM_R                                      ~26     !6, 'host'
         38        INIT_FCALL                                               'substr'
         39        FETCH_DIM_R                                      ~27     !6, 'path'
         40        SEND_VAL                                                 ~27
         41        SEND_VAL                                                 0
         42        SEND_VAL                                                 5
         43        DO_ICALL                                         $28     
         44        CONCAT                                           ~29     ~26, $28
         45        CONCAT                                           ~30     ~29, '...'
         46        INIT_FCALL                                               'substr'
         47        FETCH_DIM_R                                      ~31     !6, 'path'
         48        SEND_VAL                                                 ~31
         49        SEND_VAL                                                 -7
         50        DO_ICALL                                         $32     
         51        CONCAT                                           ~33     ~30, $32
         52        ASSIGN                                                   !7, ~33
   19    53    >   INIT_FCALL                                               'str_replace'
         54        SEND_VAR                                                 !4
         55        ISSET_ISEMPTY_CV                                         !5
         56      > JMPZ                                                     ~35, ->59
         57    >   QM_ASSIGN                                        ~36     !5
         58      > JMP                                                      ->60
         59    >   QM_ASSIGN                                        ~36     ''
         60    >   CONCAT                                           ~37     '%3Ca+href%3D%27', ~36
         61        NOP                                                      
         62        FAST_CONCAT                                      ~38     !4, '%27+target%3D%27_blank%27%3E'
         63        CONCAT                                           ~39     ~37, ~38
         64        ISSET_ISEMPTY_CV                                         !7
         65      > JMPZ                                                     ~40, ->68
         66    >   QM_ASSIGN                                        ~41     !7
         67      > JMP                                                      ->69
         68    >   QM_ASSIGN                                        ~41     !4
         69    >   CONCAT                                           ~42     ~39, ~41
         70        CONCAT                                           ~43     ~42, '%3C%2Fa%3E+'
         71        SEND_VAL                                                 ~43
         72        SEND_VAR                                                 !1
         73        DO_ICALL                                         $44     
         74        ASSIGN                                                   !1, $44
    6    75    > > JMP                                                      ->10
         76    >   FE_FREE                                                  $13
   22    77        ECHO                                                     !1
         78      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.71 ms | 1404 KiB | 23 Q