3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "Welcome to [city]. I want [city] to be a random version each time. [city] should not be the same [city] each time."; $keyword = "[city]"; $values = ["Orlando", "Dallas", "Atlanta", "Detroit", "Tampa", "Miami"]; shuffle($values); echo preg_replace_callback( '/' . preg_quote($keyword) . '/', function() use(&$values) { return array_pop($values); }, $text );

preferences:
24.23 ms | 407 KiB | 5 Q