I am making a simple wiki-style site. I have some text in database and want to make links with [link] tag.
$text = preg_replace('@\[(.*) (.*)\]@', '<a href="\\1" >\\2</a>', $text);
Now I want to change color of the link if the destination page does not exist. How it can be done?
If I insert php code in preg_replace like this:
$text = preg_replace('@[(.*) (.*)]@', '<a href="\\1" class="<?php Wiki::urlchecker($\\1) ?>">\\2</a>', $text);
it doesnt work, generates:
<a href="link" class="<?php Wiki::urlchecker($link) ?>">Name</a>