note 44800 added to function.strip-tags
| From: | IsaacSchlueterphp at isaacschlueter dot com | Date: | Tue, 17 Aug 2004 02:32:18 +0000 |
| Subject: | note 44800 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74786@lists.php.net to get a copy of this message | ||
steven --at-- acko --dot-- net pointed out that you can't make strip_slashes allow comments.
With this function, you can. Just pass <!--> as one of the allowed tags. Easy as pie: just
pull them out, strip, and then put them back.
<?php
function strip_tags_c($string, $allowed_tags = '')
{
$allow_comments = ( strpos($allowed_tags, '<!-->') !== false );
if( $allow_comments )
{
$string = str_replace(array('<!--', '-->'),
array('<!--', '-->'), $string);
$allowed_tags = str_replace('<!-->', '', $allowed_tags);
}
$string = strip_tags( $string, $allowed_tags );
if( $allow_comments ) $string = str_replace(array('<!--', '-->'),
array('<!--', '-->'), $string);
return $string;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44800
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44800&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44800&report=yes
Search -- http://master.php.net/manage/user-notes.php