3v4l.org

run code in 500+ PHP versions simultaneously
<?php $text = "[img]http://www.test.com/ abc.jpg[/img]"; $uid = 123; $text = preg_replace_callback( "#\[img]((?:https?|ftps?)://[^?&=\#\"<]*?\.(?:jpe?g|gif|png))\[/img]#i", function ($m) use ($uid) { return "[img:$uid]" . str_replace(' ', '%20', $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/Ye2r3
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%2F++abc.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%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/Ye2r3
function name:  {closure:/in/Ye2r3:8}
number of ops:  15
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        FRAMELESS_ICALL_3                str_replace         ~6      '+', '%2520'
          7        OP_DATA                                                      ~5
          8        CONCAT                                               ~7      ~2, ~6
          9        ROPE_INIT                                         3  ~9      '%5B%2Fimg%3A'
         10        ROPE_ADD                                          1  ~9      ~9, !1
         11        ROPE_END                                          2  ~8      ~9, '%5D'
         12        CONCAT                                               ~11     ~7, ~8
         13      > RETURN                                                       ~11
   10    14*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.01 ms | 1590 KiB | 14 Q