I have a large block of content. In the content, words are sometimes surrounded by [brackets], which create an auto-link. The link is a predefined file, while what is in the brackets will be added as a query string.
So far I have this:
$content = ereg_replace("([([a-zA-Z0-9_ ]+)])","<a href=\"index.php?keyword=\2\">\2</a>", $content);
This works, but, some of the words in brackets are capable of [having spaces]. So now on top of all that I need to encode the url. Is there a way to encode the url within the ereg_replace function? \2 is the actual word to link, and I have tried enclosing it in a urlencode with various periods to continue the string, with no luck.
Any ideas?
Thanks,
Will