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 );
Output for 7.2.11, 7.4.11
this bananna is bananna and Person obviously.
Output for 7.2.25, 7.4.10
this Name is Orange and Apple obviously.
Output for 7.4.9
this Think is Name and bananna obviously.
Output for 7.4.8
this bananna is bananna and Think obviously.
Output for 7.4.7
this bananna is Orange and Think obviously.
Output for 7.2.34, 7.4.6
this Person is Name and Apple obviously.
Output for 7.2.6, 7.3.17, 7.4.5
this Apple is bananna and Think obviously.
Output for 7.4.4
this Apple is Think and Name obviously.
Output for 7.4.3
this Name is Orange and Person obviously.
Output for 7.4.2
this Person is bananna and Think obviously.
Output for 7.2.31, 7.4.1
this Person is Name and Name obviously.
Output for 7.4.0
this Person is Orange and Think obviously.
Output for 7.3.23
this Think is Apple and bananna obviously.
Output for 7.3.22
this Person is Think and Person obviously.
Output for 7.3.21
this Apple is Apple and Person obviously.
Output for 7.3.20
this Think is Orange and Name obviously.
Output for 7.3.19
this Name is Name and Apple obviously.
Output for 7.3.18
this bananna is Person and Think obviously.
Output for 7.3.13, 7.3.16
this Apple is Orange and Orange obviously.
Output for 7.3.15
this Person is bananna and bananna obviously.
Output for 7.3.14
this Apple is Name and bananna obviously.
Output for 7.3.12
this Think is Orange and Apple obviously.
Output for 7.3.11
this Name is Name and Name obviously.
Output for 7.3.10
this Person is Orange and Orange obviously.
Output for 7.3.9
this Apple is bananna and Name obviously.
Output for 7.3.8
this Apple is Apple and bananna obviously.
Output for 7.2.9, 7.3.7
this bananna is Person and bananna obviously.
Output for 7.3.6
this Apple is Apple and Orange obviously.
Output for 7.2.5, 7.3.5
this Orange is Person and Think obviously.
Output for 7.3.4
this Name is Name and bananna obviously.
Output for 7.3.3
this Think is Apple and Think obviously.
Output for 7.2.15, 7.3.2
this Think is Think and Orange obviously.
Output for 7.3.1
this Apple is Person and Apple obviously.
Output for 7.3.0
this Name is Apple and Orange obviously.
Output for 7.2.33
this Name is Person and Name obviously.
Output for 7.2.32
this bananna is Name and Person obviously.
Output for 7.2.30
this Orange is Orange and Person obviously.
Output for 7.2.28 - 7.2.29
this bananna is Name and Apple obviously.
Output for 7.2.27
this Name is Apple and bananna obviously.
Output for 7.2.26
this bananna is Person and Person obviously.
Output for 7.2.24
this Person is Apple and Apple obviously.
Output for 7.2.23
this Name is Think and Name obviously.
Output for 7.2.22
this Think is Person and Name obviously.
Output for 7.2.21
this Think is Name and Think obviously.
Output for 7.2.20
this Think is Apple and Person obviously.
Output for 7.2.19
this Person is Orange and bananna obviously.
Output for 7.2.18
this Orange is bananna and bananna obviously.
Output for 7.2.17
this Person is Apple and Person obviously.
Output for 7.2.16
this Apple is Name and Orange obviously.
Output for 7.2.14
this Name is bananna and bananna obviously.
Output for 7.2.13
this Think is bananna and Think obviously.
Output for 7.2.12
this Name is Orange and bananna obviously.
Output for 7.2.10
this Think is Think and Name obviously.
Output for 7.2.8
this Think is Orange and bananna obviously.
Output for 7.2.7
this Think is Orange and Think obviously.
Output for 7.2.4
this Apple is Orange and Person obviously.
Output for 7.2.3
this Think is Person and Apple obviously.
Output for 7.2.2
this Apple is Apple and Think obviously.
Output for 7.2.1
this Orange is Think and bananna obviously.
Output for 7.2.0
this Think is Person and Person obviously.
Output for 5.5.21
this Think is bananna and Person obviously.

preferences:
52.69 ms | 784 KiB | 4 Q