I'm trying to create a url using preg_replace
but it won't let me replace a string with $variables
in it. How do I fix this?
Basically I'm trying to convert any instances of #hashtag
in $comment
with a URL.
$regex = "/#+([a-zA-Z0-9_]+)/";
$replace = '<a href="comments.php?topicID='.$topicID.'&problemID=.'$problemID.'&hashtag=$1&solution=">$0</a>';
$comment = preg_replace($regex, $replace, $comment);