here is a simple example:
$correction = \"game\";
$text =\"Hello this is an example of a $word that starts with a $dollar sign\";
$text = str_replace(\"\\$word\"
Use a regular expression and preg_replace
$correction = "game";
$text ="Hello this is an example of a \$word that starts with a \$dollar sign";
$text = preg_replace('/\$\w+/', $correction, $text);
print $text;
Something like so:
preg_replace("/(\w*)$([a-z]+)/i", "$1$correction", $text);
Note: I haven't tried it so my regex may be slightly flawed.
You'll need a regex for this:
$text = preg_replace( '/\$[a-z]+/i', 'game', $text);
A simple regex should do the trick:
$text = preg_replace("#\$[^\b\s]+#", $correction, $text);