note 80429 modified in function.strip-tags by danbrown

From: Date: Sun, 17 May 2009 15:55:59 +0000
Subject: note 80429 modified in function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154719@lists.php.net to get a copy of this message
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 --was-- This will strip all PHP and HTML out of a file. Leaves only plain txt. // 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 http://php.net/manual/en/function.strip-tags.php

« previous php.notes (#154719) next »