Kentarus's with n*****?'s idea, Using case insensitive preg_replace and checking for spaces to avoid the
www.google.com problem.
PHP Code:
static $customReplaceInit = false;
static $findtext = array();
static $replacetext = array();
if (!$customReplaceInit)
{
$textlinks = $DB_site->query(" SELECT text, link FROM " . TABLE_PREFIX . "textlink");
while($link = $DB_site->fetch_array($textlinks))
{
$findtext[] = "/\s".$link['text']."\s/i";
$replacetext[] = " [url=" . $link['link'] . "]" . $link['text'] . "[/url] ";
}
$customReplaceInit = true;
}
$bbcode=preg_replace($findtext, $replacetext, $bbcode);