3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bbcodes = [ 'Look at this:https://www.example.com/example?ohyeah=sure#okay this is a raw link', 'No attibute bbcode url: [url]http://example.com/x1[/url]', 'A url with link and link text: [url=http://example.com/x2]x2[/url]', 'Image with "ignorable" text: [IMG=sumpthing.jpg]sumpthing[/IMG]', 'Image: [img=sumpinelse][/img]' ]; $search = array ( // ... '~\[url=((?:ht|f)tps?://[a-z\d.-]+\.[a-z]{2,3}/\S*?)](.*?)\[/url]~i', '~\[url]((?:ht|f)tps?://[a-z\d.-]+\.[a-z]{2,3}/\S*?)\[/url]~i', // ... '~\[img=(.*?)].*?\[/img]~i', // if you want the possibility of dot matching newlines, add s pattern modifier // ... '~(?:<a.*?</a>|<img.*?</img>)(*SKIP)(*FAIL)|\bhttps?://.+?(?=\s|$)~im' // mop up any remaining links that are not bbtagged ); $replace = array ( // ... '<a href="$1" target="_blank">$2</a>', '<a href="$1" target="_blank">$1</a>', // ... '<img src="$1"></img>', // ... '<a href="$0" target="_blank">$0</a>', ); var_export(preg_replace($search, $replace, $bbcodes));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G5lem
function name:  (null)
number of ops:  12
compiled vars:  !0 = $bbcodes, !1 = $search, !2 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   19     2        ASSIGN                                                   !2, <array>
   28     3        INIT_FCALL                                               'var_export'
          4        INIT_FCALL                                               'preg_replace'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.57 ms | 1010 KiB | 15 Q