3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = ['yellow', 'green', 'red']; $myString = 'banana is ?, apple is ?, tomato is ?'; echo preg_replace_callback( '/\?/', function() use ($myArray) { static $i = 0; return $myArray[$i++]; }, $myString );

preferences:
31.1 ms | 404 KiB | 5 Q