Jump to content

BBcode parsing (url)


mikelmao

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.