intert too many links

Jan 24, 2011 at 12:04 AM

I want to do this.

I add to many links. for example

http://www.protectlinks.com/293
http://www.protectlinks.com/294
http://www.protectlinks.com/295
http://www.protectlinks.com/296

and I want to this with only one clicks

[url]http://www.protectlinks.com/293[/url]
[url]http://www.protectlinks.com/294[/url]
[url]http://www.protectlinks.com/295[/url]
[url]http://www.protectlinks.com/296[/url]

 

How can I do that ?

Mar 3, 2011 at 10:19 AM
Edited Mar 3, 2011 at 10:22 AM

Do it in the php-parser ;) it's easier I think (at least for me :P)

 

//search for example [url=http://www.google,de/]Google[/url]
$newtext = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/", "<a href=\"\\1\" target='_blank'>\\2</a>", $oldtext);
//search for [url]link[/url] or [URL]link[/URL] and replaced it t a normal link without any tags or BBcodes
$newtext = preg_replace("/\[url\]www.(.*)\[\/url\]/isU", "http://www.$1", $oldtext);
//this function you are looking for -> search for a normal Link and replaced it
$newtext = preg_replace('#(^|[^"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm','\1<a href="\2\3">\2\3</a>\4',$oldtext);


You see actually you don't need this function in your WYSIWYG-Editor ;)