Page 1 of 1

Can some1 explain this 2 me

Posted: Tue Oct 01, 2002 4:01 pm
by Knifee
$data = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2" target="_blank">\\2</a>', $data);

$data = eregi_replace('([[:space:]()[{}])(http://[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="\\2" target="_blank">\\2</a>', $data);
I am trying to build a page that uses popup windows for some of it links, i was wondering if i could use a modified version of this script to change links typed in to text to the java link. eg: if some1 writes:

[POPUP]http://mypage.htm.

then the script could change it to:
<p class="smalltext" onMouseOver="MM_openBrWindow('http://pypage.htm','popup','width=600,height=400')">click here</p>

but if they wrote [link]http://mypage.htm. then it would change it to <a href="mypage.htm target="_blank">click here</a>

NE way that what i was hopeing to do, but really i was hopeing some1 could explain how that script works, cous i've been learning php for about 6hours and i've been doing ok, but this stumped me :)

Posted: Wed Oct 02, 2002 10:23 am
by dusty

Code: Select all

$data = preg_replace("/\&#1111;POPUP\](.+)\&#1111;\/POPUP\]/iU","&lt;p class="smalltext" onMouseOver="MM_openBrWindow('$1','popup','width=600,height=400')"&gt;click here&lt;/p&gt;",$data);
$data = preg_replace("/\&#1111;LINK\](.+)\&#1111;\/LINK\]/iU","&lt;a href="$1" target="_blank"&gt;click here&lt;/a&gt;",$data);
ie usage:
[POPUP]http://www.mylink.com[/POPUP]
[LINK]http://www.mylink.com[/LINK]