3v4l.org

run code in 300+ PHP versions simultaneously
<?php $randoms = array_flip([ "Name", "Think", "Person", "Apple", "Orange", "bananna" ]); $string = 'this {random} is {random} and {random} obviously.'; echo preg_replace_callback( '~\{random}~', function() use ($randoms) { return array_rand($randoms); }, $string );

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
154.3 ms | 1402 KiB | 11 Q