teamer Posted June 15, 2010 Share Posted June 15, 2010 Hi all i have text in database with the following stuff > and < and stuff like that . well guests enter text that is saved to the database , and when it is printed out i don't want it to be parsed so converting all HTML entities to > and < is enough . BUT i want to allow some HTML tags to be converted back to normal like <font size=4>text</font> so i wrote the following regex where $alowed_ones='font|b|center|i|a'; $data=preg_replace('/(<)('.$alowed_ones.')((\s)(.*))?(>)(.*)(<\/)('.$alowed_ones.')(>)/ims' , '<\\2\\3>\\7</\\9>', $data,-1); but for example if i $data was <center><a href="fF">Xx"</a></center> only the <center></center> is back to normal and the <a> tag is not parsed unless i run the preg_replace again !!! any way to do it without having to call it back ??? plz help Quote Link to comment https://forums.phpfreaks.com/topic/204864-preg_replace/ 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.