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 );

preferences:
58.54 ms | 788 KiB | 5 Q