ShaolinF Posted December 18, 2009 Share Posted December 18, 2009 Hi Guys I am using strip_tags() to remove unwanted html. I am using the allowed tags param to add all the tags which are acceptable. The problem is I would like most HTML tags in the allowed tags parameter but it'll be too long to just add all of them. Is there a shortcut ? Link to comment https://forums.phpfreaks.com/topic/185629-strip_tags-allowed-parameters/ Share on other sites More sharing options...
Mchl Posted December 18, 2009 Share Posted December 18, 2009 Perhaps instead use regex to remove these tags you wish to have removed. Link to comment https://forums.phpfreaks.com/topic/185629-strip_tags-allowed-parameters/#findComment-980215 Share on other sites More sharing options...
ShaolinF Posted December 18, 2009 Author Share Posted December 18, 2009 any examples ? I would still have to specify each tag that needs to be removed so it adds up ..? Link to comment https://forums.phpfreaks.com/topic/185629-strip_tags-allowed-parameters/#findComment-980220 Share on other sites More sharing options...
mrMarcus Posted December 18, 2009 Share Posted December 18, 2009 any examples ? I would still have to specify each tag that needs to be removed so it adds up ..? well, you can't have it both ways. either you gotta type in the ones that are allowed or the ones that aren't. <?php function strip_some_tags($input) { $search = array( '@<script[^>]*?>.*?</script>@si', // Strip javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<b[^>]*?>.*?</b>@siU', // Strip <b> tags '@<a[^>]*?>.*?</a>@siU', // Strip <a> tags '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments ); $input = preg_replace($search, '', $input); return $input; } ?> function strips tags from inputted content. Link to comment https://forums.phpfreaks.com/topic/185629-strip_tags-allowed-parameters/#findComment-980222 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.