3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = "{three/fifteen/one hundred} this is the first random number, and this is the second, {two/four}"; echo preg_replace_callback('~\{([^{}]*)}~', function ($x) { return array_rand(array_flip(explode('/', $x[1]))); }, $str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GVFnm
function name:  (null)
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%7Bthree%2Ffifteen%2Fone+hundred%7D+this+is+the+first+random+number%2C+and+this+is+the+second%2C+%7Btwo%2Ffour%7D'
    4     1        INIT_FCALL                                                   'preg_replace_callback'
          2        SEND_VAL                                                     '%7E%5C%7B%28%5B%5E%7B%7D%5D%2A%29%7D%7E'
          3        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
    6     4        SEND_VAL                                                     ~2
          5        SEND_VAR                                                     !0
    4     6        DO_ICALL                                             $3      
    6     7        ECHO                                                         $3
          8      > 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/GVFnm
function name:  {closure:/in/GVFnm:4}
number of ops:  14
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
    5     1        INIT_FCALL                                                   'array_rand'
          2        INIT_FCALL                                                   'array_flip'
          3        INIT_FCALL                                                   'explode'
          4        SEND_VAL                                                     '%2F'
          5        FETCH_DIM_R                                          ~1      !0, 1
          6        SEND_VAL                                                     ~1
          7        DO_ICALL                                             $2      
          8        SEND_VAR                                                     $2
          9        DO_ICALL                                             $3      
         10        SEND_VAR                                                     $3
         11        DO_ICALL                                             $4      
         12      > RETURN                                                       $4
    6    13*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.5 ms | 1389 KiB | 17 Q