I am struggling a lot with coding something currently. I am basically trying to do a very very very simple wiki style of internal linking on my site. I have gotten it so that with ereg_replace I can convert [[test]] to <a href='http://www.mysite.com/page?id=test'>test</a>, the problem is that I need to make it so that if the id is Joe Bloggs that it makes the id value in the link Joe_Bloggs.

Code:
$output = ereg_replace("\\[\\[([^\[]*)\\]\\]","<a href=\"http://www.mysite.com/dir/\\1\">\\1</a>",$input);
Any idea how I can do this please?