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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.