mikelmao Posted December 30, 2008 Share Posted December 30, 2008 Hey. I Recently found out how i could make BBCode's.. I would like to know, How can i make a Url BB Code? As in: THIS: to <a href='http://google.com'></a> How do i get those values? please help. Thank you Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/ Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 No-one knows? Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726248 Share on other sites More sharing options...
dMilesFox Posted December 30, 2008 Share Posted December 30, 2008 THIS: its empty! Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726252 Share on other sites More sharing options...
opalelement Posted December 30, 2008 Share Posted December 30, 2008 THIS: its empty! because this board parsed it preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/", "<a href=\"\\1\" target=\"_blank\">\\2</a>", $text_body); Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726256 Share on other sites More sharing options...
flyhoney Posted December 30, 2008 Share Posted December 30, 2008 Uhm... The BBcode for url is: [ url=http://www.example.com]Check out this awesome website![ /url] Are you asking how to write BBcode or parse BBcode? Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726257 Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 Whats the diff? (Sorry im very new to PHP.. and im trying to learn) Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726279 Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 Hello? Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726339 Share on other sites More sharing options...
Absorbator Posted December 30, 2008 Share Posted December 30, 2008 Hi there, If you want this www.google.com to became <a href>www.google.com</a> then use this code $outputString=preg_replace('/\[url\](.*?)\[\/url\]/is', "<a href='$1' title='$1'>$1</a>", $inputString); BUT if you want something more advanced then use this $ouputString=preg_replace('/\[url\=(.*?)\](.*?)\[\/url\]/is', "<a href=$1>$2</a>", $inputString); I hope this helps Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726364 Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 i dont understand it please explain Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726387 Share on other sites More sharing options...
flyhoney Posted December 30, 2008 Share Posted December 30, 2008 Can you explain what you need to do a little better? Like, the context of the problem you are solving. Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726393 Share on other sites More sharing options...
Absorbator Posted December 30, 2008 Share Posted December 30, 2008 i dont understand it please explain Look dude, I think you've messed with the "Regular Expressions" and you just cannot understand them. If this is the case, then Google them. As you see, you use "preg_replace" function, instead of "str_replace" and this is the trick. ---------------- Now playing: Metallica - Nothing Else Matters via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726448 Share on other sites More sharing options...
mikelmao Posted December 30, 2008 Author Share Posted December 30, 2008 i just want a BB_Code. when i type in a Text Field [url=google.com]Click here[/url] it looks like Click here Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-726450 Share on other sites More sharing options...
opalelement Posted January 1, 2009 Share Posted January 1, 2009 i just want a BB_Code. when i type in a Text Field [url=google.com]Click here[/url] it looks like Click here if you were to make it only to google.com then it would be trying to find a directory within the cwd named "google.com", otherwise you need more checking to look for the http:// you need to understand regex to do it Link to comment https://forums.phpfreaks.com/topic/138877-bbcode-parsing-url/#findComment-727541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.