Jump to content

help needed with $strip_tags


kev wood

Recommended Posts

i have just been looking at the strip tags function within php.  what i want it to do is go through a page and take out any unwanted symbols in my a href tags.  I am using a wysiwyg html editor on the backend of a site.  when the user creates a link using this editor it is adding \ to the code.

 

is it possible to get this function to go through all the tags and delete the unwanted \ from the tags.  If it can be done can someone show me a tutorial on how to complete this task.  if this function can not do this can someone point me in the direction of the correct function to use.

Link to comment
Share on other sites

yes it a pain in the ar*e i have just been looking at the preg_replace function then and was just about to post that up here.  the question i have about that tho is how can i get it to only search through the links that have been generated.

Link to comment
Share on other sites

if i want it to work through the whole page what would i have $data set to. could i have $data set to the page name and have this on its own php page and then call this function at the top  of the page.

 

also how would i only get it to work through the a href tags as some slashes could have been added by the user for visual representation.

Link to comment
Share on other sites

<?php
$data = "let me guess. it\'s adding stuff like \"this\"?";
$data = str_replace("\'", "'", $data);
print $data;

 

or you could use

print stripslashes( "let me guess. it\'s adding stuff like \"this\"?" );

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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