[code=php]<?php // if someone tries to access this file directly from a browser, block them
if (realpath(__FILE__) == realpath($_SERVER[‘DOCUMENT_ROOT’] . ‘/’ . $_SERVER[‘SCRIPT_NAME’]))
{
die(‘Access Denied’);
}
function BBCODE($input)
{
$pattern = array();
$pattern[0] = “/[[Bb]](.*)[/[Bb]]/”;
$pattern[1] = “/[[Ii]](.*)[/[Ii]]/”;
$pattern[2] = “/[url=(.*)](.*)[/url]/i”;
$replace = array();
$replace[0] = “<b>$1</b>”;
$replace[1] = “<i>$1</i>”;
$replace[2] = “<a href=”$1″ target=”_blank”>$1</a>”;
$input = preg_replace($pattern, $replace, $input);
return $input;
}
?>
Okay, so I’m using REGEX to format my BBCode. The bold and italic both come out fine, but when I try to use url, something weird happens. It formats it into a url, but for some reason, it does so by adding the url as an extension to your current url. Instead of posting the link to go to [url]www.something.com[url]www.something.com/directory/www.something.com
What should I do to fix this?