note 80429 deleted from function.strip-tags by googleguy
| From: | googleguy@php.net | Date: | Mon, 11 Feb 2013 05:14:11 +0000 |
| Subject: | note 80429 deleted from function.strip-tags by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193581@lists.php.net to get a copy of this message | ||
Note Submitter: bstrick at gmail dot com
----
This will strip all PHP and HTML out of a file. Leaves only plain txt.
<?php
// Open the search file
$file = fopen($filename, 'r');
// Get rid of all PHP code.
$search = array('/<\?((?!\?>).)*\?>/s');
$text = fread($file, filesize($filename));
$new = strip_tags(preg_replace($search, '', $text));
echo $new;
fclose($file);
?>
- Strick