Hi all, ive made a function that converts plaintext links, into [.url]link here[/url.]
style links.
function convert_links($str) {
$disallow = array('[url]','[img]');
if(!eregi($disallow,$str)) {
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
"[url]\\0[/url]", $str);
}
return $str;
}
The problem is, i only want to convert these links if they are plain text. If the link is already wrapped in URL bbcodes, or IMG bb codes, then i dont want to convert it, b/c then it will have double URL and IMG bb codes.
This function is not working properly, in the respects that for some reason if the string already contains URL or IMG codes, its still converting them.
What is wrong with it?