3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bbcodes = [ '[URL]www.no.http.example.com[/URL]', '[url]https://any.com/any[/url]', '[url="nourl"]nourl[/url]', '[URL="https://any.com/any?any=333"]text text[/URL]', '[url="http://www.emptyTEXT.com"][/url]', '[url]http://www.any.com/any?any=44#sss[/url]', '[url="https://conflictinglink"]http://differenturl[/url]' ]; foreach ($bbcodes as $bbcode) { echo preg_replace('~\[url(?|]((https?://[^[]+))|(?:="(https?://[^"]+)")](.+?))\[/url]~i', '<a href=\"$1\">$2</a>', $bbcode); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/PSuJi
function name:  (null)
number of ops:  13
compiled vars:  !0 = $bbcodes, !1 = $bbcode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1      > FE_RESET_R                                       $3      !0, ->11
          2    > > FE_FETCH_R                                               $3, !1, ->11
   13     3    >   INIT_FCALL                                               'preg_replace'
          4        SEND_VAL                                                 '%7E%5C%5Burl%28%3F%7C%5D%28%28https%3F%3A%2F%2F%5B%5E%5B%5D%2B%29%29%7C%28%3F%3A%3D%22%28https%3F%3A%2F%2F%5B%5E%22%5D%2B%29%22%29%5D%28.%2B%3F%29%29%5C%5B%2Furl%5D%7Ei'
          5        SEND_VAL                                                 '%3Ca+href%3D%5C%22%241%5C%22%3E%242%3C%2Fa%3E'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8        ECHO                                                     $4
   14     9        ECHO                                                     '%0A---%0A'
   12    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $3
   15    12      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.4 ms | 1009 KiB | 14 Q