How to make wikified links in php

If you are using output buffering, it’s pretty simple. Add this code at the bottom. It will parse text that are marked with [[..]] and transform it inot a link to the selected wiki page. so a text like [[wiki]] will transform into

$contents = ob_get_contents();      

$yourwikipage="/mediawiki/index.php"; 

ob_clean ( );      

$pattern = '/\[\[(([^\]]*?))\]\]/';      

// $pattern = "/<<(.*)>>/is";     

$contents = preg_replace($pattern, "</a><a href="%5C%22$yourwikipage/$1%5C%22" target="wiki">$1</a>", $contents);     

print ($contents);       

ob_end_flush();