I am having problems with trying to remove some tags using PHP. What I
want is to perform a search and replace on a URL, so if someone tried to
put a URL into a guestbook database, instead of the user inputting a
link as:
<a href="http://whatever.com">visit me</A>
It goes into the database as:
http://whatever.com
I have tried the str_replace() function, but doesn't seem to work. I have
also tried strip_tags() but then that just give the result:
visit me
This is the code I've written.
$AmendedComment = str_replace("<a href=\"", " ", $_POST['Comment']);
$FinalComment = addslashes($AmendedComment);
Checking the database and reading it out again, the first part of the URL
remains intact, so the URL is clickable - not what I want.
I've made an attempt at preg_replace() but it's difficult to get head
around trying to write a pattern.
Any help appreciated.
Dariusz