3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text ="I found some really good articles on such and such topic. Here are a few links to check out: http://www.example.com/hOSDHOUA and https://www.mywebsite.com/h/yIFeelLowIfImHigh and http://example-site.com/today-is-a-beautiful-day/. "; $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; // The Text you want to filter for urls // Check if there is a url in the text if(preg_match_all($reg_exUrl, $text, $url)) { foreach($url[0] as $link){ $text = str_replace($link, "<a href={$link}>{$link}</a> ", $text); // <--- Part in question } echo $text; } else { // if no urls in the text just return the text echo $text; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W4ifF
function name:  (null)
number of ops:  28
compiled vars:  !0 = $text, !1 = $reg_exUrl, !2 = $url, !3 = $link
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'I+found+some+really+good+articles+on+such+and+such+topic.+Here+are+a+few+links+to+check+out%3A+http%3A%2F%2Fwww.example.com%2FhOSDHOUA+and+https%3A%2F%2Fwww.mywebsite.com%2Fh%2FyIFeelLowIfImHigh+and+http%3A%2F%2Fexample-site.com%2Ftoday-is-a-beautiful-day%2F.+'
    3     1        ASSIGN                                                   !1, '%2F%28http%7Chttps%7Cftp%7Cftps%29%5C%3A%5C%2F%5C%2F%5Ba-zA-Z0-9%5C-%5C.%5D%2B%5C.%5Ba-zA-Z%5D%7B2%2C3%7D%28%5C%2F%5CS%2A%29%3F%2F'
    7     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $6      
          7      > JMPZ                                                     $6, ->26
    8     8    >   FETCH_DIM_R                                      ~7      !2, 0
          9      > FE_RESET_R                                       $8      ~7, ->23
         10    > > FE_FETCH_R                                               $8, !3, ->23
    9    11    >   INIT_FCALL                                               'str_replace'
         12        SEND_VAR                                                 !3
         13        ROPE_INIT                                     5  ~10     '%3Ca+href%3D'
         14        ROPE_ADD                                      1  ~10     ~10, !3
         15        ROPE_ADD                                      2  ~10     ~10, '%3E'
         16        ROPE_ADD                                      3  ~10     ~10, !3
         17        ROPE_END                                      4  ~9      ~10, '%3C%2Fa%3E+'
         18        SEND_VAL                                                 ~9
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $13     
         21        ASSIGN                                                   !0, $13
    8    22      > JMP                                                      ->10
         23    >   FE_FREE                                                  $8
   11    24        ECHO                                                     !0
         25      > JMP                                                      ->27
   14    26    >   ECHO                                                     !0
   15    27    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.03 ms | 1396 KiB | 17 Q