3v4l.org

run code in 300+ 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);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
164.85 ms | 1402 KiB | 15 Q