3v4l.org

run code in 300+ PHP versions simultaneously
<?php $phrase = "The key is now set to :key"; $key = ":key"; $var = "if > $1000"; $re = "/(.+?)(" . $key . ")(.*)/"; $subst = "\1'" . $var . "'\3"; echo preg_replace($re, $subst, $phrase);

preferences:
51.28 ms | 402 KiB | 5 Q