The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Strip Bad HTML Tags
Posted by: Stephen | February 18, 2007 @ 5:27pm
PHP Code
[
Download
]
<?php // Source: http://us2.php.net/filters // This code will only allow certain HTML tags --- <B>, <U>, and <I> in this example $fp = fopen('php://output', 'w'); stream_filter_append($fp, 'string.strip_tags', STREAM_FILTER_WRITE, "<b><i><u>"); fwrite($fp, "<b>bolded text</b> enlarged to a <h1>level 1 heading</h1>\n"); fclose($fp); /* Outputs: <b>bolded text</b> enlarged to a level 1 heading */ ?> <HR> Another way to do this: <HR> <?php $fp = fopen('php://output', 'w'); stream_filter_append($fp, 'string.strip_tags', STREAM_FILTER_WRITE, array('b','i','u')); fwrite($fp, "<b>bolded text</b> enlarged to a <h1>level 1 heading</h1>\n"); fclose($fp); /* Outputs: <b>bolded text</b> enlarged to a level 1 heading */ ?>
Syntax Highlighting
[
Open in new window
]
Author Comments
This is a code snippet from the PHP manual. It will strip all but certain HTML tags.
Rating
4.51 / 8
334 Votes