Jump to content

Help with links


day_tripperz

Recommended Posts

Ok im having problems stoping site links being posted on my wap site im using php 4 and i can only manage to stop certain links i want to stop all i use this code to stop one link

$gbvalues=str_replace('http://www.site.co.uk','<img src="image/hatespammers.gif" alt="(hatespammers)',$gbvalues);

and that replaces the link with my hate spammers icon. But it only stops [a href=\"http://www.site.co.uk\" target=\"_blank\"]http://www.site.co.uk[/a] from being put up in the forums. Please help thanks in advanced

Link to comment
https://forums.phpfreaks.com/topic/44136-help-with-links/
Share on other sites

You need to use somethin like preg_replace, with a regular expression similar to:

 

$text=preg_replace('/\[a href\=(.*?)\]/si','<img src="image/hatespammers.gif" alt="(hatespammers)',$gbvalues);

 

That will replace any text that begins with "[a href= until the next ]" and replace it with your image. However, you may need to change this if the actual code the users are entering is or html with < brackets. Good luck.

 

 

Link to comment
https://forums.phpfreaks.com/topic/44136-help-with-links/#findComment-214307
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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