Jump to content

strip_tags() allowed parameters


ShaolinF

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

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