3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = 'This is just a test {#3,2,7,9} this is another test {#21,2,11}'; echo preg_replace_callback('/{[#]([\w,]{1,})}/', function ($match) { $numbers = explode(',', $match[1]); shuffle($numbers); return isset($numbers[0]) ? $numbers[0] : '{#'.$match[0].'}'; }, $str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luCAT
function name:  (null)
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 'This+is+just+a+test+%7B%233%2C2%2C7%2C9%7D+this+is+another+test+%7B%2321%2C2%2C11%7D'
    4     1        INIT_FCALL                                                   'preg_replace_callback'
          2        SEND_VAL                                                     '%2F%7B%5B%23%5D%28%5B%5Cw%2C%5D%7B1%2C%7D%29%7D%2F'
          3        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
    8     4        SEND_VAL                                                     ~2
          5        SEND_VAR                                                     !0
    4     6        DO_ICALL                                             $3      
    8     7        ECHO                                                         $3
          8      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luCAT
function name:  {closure:/in/luCAT:4}
number of ops:  21
compiled vars:  !0 = $match, !1 = $numbers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
    5     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%2C'
          3        FETCH_DIM_R                                          ~2      !0, 1
          4        SEND_VAL                                                     ~2
          5        DO_ICALL                                             $3      
          6        ASSIGN                                                       !1, $3
    6     7        INIT_FCALL                                                   'shuffle'
          8        SEND_REF                                                     !1
          9        DO_ICALL                                                     
    7    10        ISSET_ISEMPTY_DIM_OBJ                             0          !1, 0
         11      > JMPZ                                                         ~6, ->15
         12    >   FETCH_DIM_R                                          ~7      !1, 0
         13        QM_ASSIGN                                            ~8      ~7
         14      > JMP                                                          ->19
         15    >   FETCH_DIM_R                                          ~9      !0, 0
         16        CONCAT                                               ~10     '%7B%23', ~9
         17        CONCAT                                               ~11     ~10, '%7D'
         18        QM_ASSIGN                                            ~8      ~11
         19    > > RETURN                                                       ~8
    8    20*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.59 ms | 1264 KiB | 16 Q