July 6, 200620 yr Hey guys, I have a slight issue here, I have a function for bbcode that I have made... function bbcode($txt){ $txt = htmlspecialchars($txt); $txt = preg_replace_callback('#\[php\](.+?)\[/php\]#msi',create_function('$matches', 'return highlight_string($matches[1], true);'), $txt); $txt = preg_replace('#\[b\](.+?)\[/b\]#msi', '\\1', $txt); $txt = preg_replace('#\[i\](.+?)\[/i\]#msi', '\\1', $txt); $txt = preg_replace('#\[u\](.+?)\[/u\]#msi', '\\1', $txt); $txt = preg_replace('#\[url=(.+?)\](.+?)\[/url\]#msi','\\2', $txt); $txt = preg_replace('#\[url\](.+?)\[/url\]#msi','\\1', $txt); $txt = preg_replace('#\[img](.+?)\[/img\]#msi','',$txt); $txt = preg_replace('#\[quote name=(.+?)\](.+?)\[/quote\]#msi','</pre><table width="75%" align="center" cellpadding="2" cellspacing="1">Quoting: \\1\\2</table>',$txt);<br><br><br><br>$txt = nl2br($txt);<br><br><br><br> return $txt;<br><br><br><br>}<b That works just fine, but now for the issue. In phpBB, if you just type a url, it'll transform it for you http://www.clan-forge.net/ Such as that (Thats my website btw) and also bbcode ( tags, things like that) But it does both, I cannt get my function to do both without it contradicting the other... suggestions?
July 7, 200620 yr you can search the string for url if its found parse it, if its not found search for just http:// and parse the string until the trailing space
Create an account or sign in to comment