PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
qads
DevNet Resident
Posts: 1199 Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane
Post
by qads » Tue Sep 10, 2002 8:32 pm
hi,
how can i turn all the urls/website addresses in $block_from_db into clickble links?
Code: Select all
<?php $block_from_db = "today www.site.com had blah blah with www.site-com.com";
print("$block_from_db");?>
like this forum turns any link into a clickble link, .e.g.
http://www.somesite.com
i have no idea how to do it, i have searched quite alot of places but have't found anything for this.
please help
dusty
Forum Contributor
Posts: 122 Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA
Post
by dusty » Tue Sep 10, 2002 8:51 pm
Code: Select all
$block_from_db = preg_replace("/((http:\/\/)|(www\.))(ї\S\.]+)\b/i", "<a href="http://$3$4$5">$2$3$4$5</a>", $block_from_db);
Last edited by
dusty on Tue Sep 10, 2002 9:22 pm, edited 1 time in total.
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Tue Sep 10, 2002 8:51 pm
Code: Select all
$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);
does the trick for me.
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Tue Sep 10, 2002 10:38 pm
I get easily confuzed when I see the /^#$^3461/234!@%25 stuff.
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Tue Sep 10, 2002 10:51 pm
it's just a list of characters that can be used in URL's
qads
DevNet Resident
Posts: 1199 Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane
Post
by qads » Wed Sep 11, 2002 8:42 am
very nice
, thanks alot!