3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "[img]http://www.test.com/abc.jpg[/img]"; $uid = 123; $text = preg_replace_callback( "#\[img]((?:https?|ftps?)://[^\s?&=\#\"<]*?\.(?:jpe?g|gif|png))\[/img]#i", function ($m) use ($uid) { return "[img:$uid]" . $m[1] . "[/img:$uid]"; }, $text ); echo $text;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g05dX
function name:  (null)
number of ops:  12
compiled vars:  !0 = $text, !1 = $uid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5Bimg%5Dhttp%3A%2F%2Fwww.test.com%2Fabc.jpg%5B%2Fimg%5D'
    4     1        ASSIGN                                                   !1, 123
    6     2        INIT_FCALL                                               'preg_replace_callback'
    7     3        SEND_VAL                                                 '%23%5C%5Bimg%5D%28%28%3F%3Ahttps%3F%7Cftps%3F%29%3A%2F%2F%5B%5E%5Cs%3F%26%3D%5C%23%22%3C%5D%2A%3F%5C.%28%3F%3Ajpe%3Fg%7Cgif%7Cpng%29%29%5C%5B%2Fimg%5D%23i'
    8     4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   10     6        SEND_VAL                                                 ~4
   11     7        SEND_VAR                                                 !0
    6     8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !0, $5
   14    10        ECHO                                                     !0
   15    11      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g05dX
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $m, !1 = $uid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    9     2        ROPE_INIT                                     3  ~3      '%5Bimg%3A'
          3        ROPE_ADD                                      1  ~3      ~3, !1
          4        ROPE_END                                      2  ~2      ~3, '%5D'
          5        FETCH_DIM_R                                      ~5      !0, 1
          6        CONCAT                                           ~6      ~2, ~5
          7        ROPE_INIT                                     3  ~8      '%5B%2Fimg%3A'
          8        ROPE_ADD                                      1  ~8      ~8, !1
          9        ROPE_END                                      2  ~7      ~8, '%5D'
         10        CONCAT                                           ~10     ~6, ~7
         11      > RETURN                                                   ~10
   10    12*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.27 ms | 1001 KiB | 14 Q