kev wood Posted July 23, 2008 Share Posted July 23, 2008 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. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted July 23, 2008 Share Posted July 23, 2008 let me guess. it\'s adding stuff like \"this\"? well, here's a simple solution: <?php $data = "let me guess. it\'s adding stuff like \"this\"?"; $data = str_replace("\'", "'", $data); print $data; something like that. Quote Link to comment Share on other sites More sharing options...
kev wood Posted July 23, 2008 Author Share Posted July 23, 2008 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. Quote Link to comment Share on other sites More sharing options...
Jabop Posted July 23, 2008 Share Posted July 23, 2008 The method posted above will work just fine, however, if you want to rid of the issue entirely then you should turn off magic quotes in your php.ini Quote Link to comment Share on other sites More sharing options...
kev wood Posted July 23, 2008 Author Share Posted July 23, 2008 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. Quote Link to comment Share on other sites More sharing options...
adam84 Posted July 23, 2008 Share Posted July 23, 2008 <?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\"?" ); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.