3v4l.org

run code in 500+ 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:  9
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        FRAMELESS_ICALL_3                preg_replace        ~6      !1, !2
          5        OP_DATA                                                      !0
          6        SEND_VAL                                                     ~6
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
221.61 ms | 3579 KiB | 14 Q