Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace string problem

Status
Not open for further replies.

ckennerdale

Programmer
Dec 23, 2000
158
GB
what I wantto do it to take a string out of a mysql database,and strip allhtml/ email tags that have been inserted in.

So I have text similar to
'<a href=&quot;mailto:foo@foo.com&quot;>foo@foo.com</a>'

and I want it turn into just 'foo@foobar.com'. Obviously the actual email addresses or web addresses will vary.

I have used eregi_replace before with success,but here the stuff that needs to be stripped or replaced will vary.(as emails vary)


#Ultimately what I am trying to acheive is this-

I have an 'add' form into my database which adds special charaters, <br> lines etc.However when I pull down the record into mt 'edit' page , it also pulls down the special formattingI havedone- which is fine,but when I update the record ,it parses through the process again.Thjis results in allmy urls, emails and <br> lines doubling.

So I reckoned that if I strippedthem out for the editing view and then reapplied the formatting to the whole string as I update the database this wouldbe the best courseof action.

Any ideas? Caspar Kennerdale
Senior Media Developer
 
I don't know if this will help, but there's a special function just for removing html AND PHP tags in PHP.
it's called 'strip_tags' and it has two parameters.

The first one is the string you are stripping

and the second one are tags that you don't want stripped.

Example:

new_string = strip_tags(old_string);

Bostjan
 
Luftwalk:

Your code is wrong:

new_string = strip_tags(old_string);

should be

$new_string = strip_tags($old_string);

That should work.

-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top