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_callback('~\[url(?:](https?://[^[]+)|(?:="(https?://[^"]+)")](.+?))\[/url]~i', function($m) { if (isset($m[2])) { return "<a href=\"{$m[2]}\">{$m[3]}</a>"; } return "<a href=\"{$m[1]}\">{$m[1]}</a>"; }, $bbcode); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/ppnEY
function name:  (null)
number of ops:  14
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, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   13     3    >   INIT_FCALL                                               'preg_replace_callback'
          4        SEND_VAL                                                 '%7E%5C%5Burl%28%3F%3A%5D%28https%3F%3A%2F%2F%5B%5E%5B%5D%2B%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'
   14     5        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
   19     6        SEND_VAL                                                 ~4
   20     7        SEND_VAR                                                 !1
   13     8        DO_ICALL                                         $5      
   20     9        ECHO                                                     $5
   21    10        ECHO                                                     '%0A---%0A'
   12    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   22    13      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ppnEY
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 2
          2      > JMPZ                                                     ~1, ->11
   16     3    >   ROPE_INIT                                     5  ~5      '%3Ca+href%3D%22'
          4        FETCH_DIM_R                                      ~2      !0, 2
          5        ROPE_ADD                                      1  ~5      ~5, ~2
          6        ROPE_ADD                                      2  ~5      ~5, '%22%3E'
          7        FETCH_DIM_R                                      ~3      !0, 3
          8        ROPE_ADD                                      3  ~5      ~5, ~3
          9        ROPE_END                                      4  ~4      ~5, '%3C%2Fa%3E'
         10      > RETURN                                                   ~4
   18    11    >   ROPE_INIT                                     5  ~11     '%3Ca+href%3D%22'
         12        FETCH_DIM_R                                      ~8      !0, 1
         13        ROPE_ADD                                      1  ~11     ~11, ~8
         14        ROPE_ADD                                      2  ~11     ~11, '%22%3E'
         15        FETCH_DIM_R                                      ~9      !0, 1
         16        ROPE_ADD                                      3  ~11     ~11, ~9
         17        ROPE_END                                      4  ~10     ~11, '%3C%2Fa%3E'
         18      > RETURN                                                   ~10
   19    19*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.02 ms | 1015 KiB | 14 Q