I have a bbCode function I made:
function bbCode($str)
{
$values = array(
'@\[link="(.*?)"\](.*?)\[\/link\]@i' => '<a href="$1">$2</a>'
);
return preg_replace(array_keys($values), array_values($values), $str);
}
It works well but if the user types, for example [link="google.com"]Something[/link], the result would be
<a href="google.com">Something</a>
And that would return to www.mywebsite.com/google.com How could I prevent this from happening?