In the code below I’m trying to take some text and wrap a html achor around it:
$d = "hello, there, how, are, you";
$d = preg_replace("/[a-zA-Z]+/", "<a href='?word=$1'>$1</a>", $d);
It correctly identifies each word and replaces each one with the replacement text BUT it doesn’t put the matched word into the string, it just leaves it blank. I’m on PHP5. What am I missing?
Thanks in advance.
You forgot to capture the matches: