<?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 );
You have javascript disabled. You will not be able to edit any code.