Forum Moderators: coopster

Message Too Old, No Replies

Changing the Link code of a URL

         

Gian04

2:58 pm on Apr 6, 2008 (gmt 0)

10+ Year Member



I have a site that accepts user comment that allows them to submit even an HTML code.

Now I just want to programmatically change their post if they submitted a link

example:
if they submitted http://www.example.com

it will become
[mydomain.com?redirect=http:...]

FourDegreez

3:52 pm on Apr 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



preg_replace('/http:\/\/([a-z0-9\.\/,_-]+)/i', '<a href="http://www.mydomain.com?redirect=$0">$0</a>', $text);

where $text is the body of the post.