note 63791 deleted from function.php-strip-whitespace by bjori

From: Date: Tue, 04 Apr 2006 09:22:17 +0000
Subject: note 63791 deleted from function.php-strip-whitespace by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107273@lists.php.net to get a copy of this message
Note Submitter: heavyraptor ---- I made this alternate function for PHP-Version < 5.0.1, it does the same thing (I used token_get_all() to remove whitespace and comments). I'm not sure but I don't think that php_strip_whitespace() removes T_ENCAPSED_AND_WHITESPACE, that's why I ignored that. <?php if (!function_exists("php_strip_whitespace")) { function php_strip_whitespace($filename) { if (!file_exists($filename)) return false; $tokens = token_get_all(file_get_contents($filename)); $ret = ""; foreach ($tokens as $token) { if (!in_array($token[0],array(T_COMMENT,T_DOC_COMMENT,T_WHITESPACE))) $ret .= $token[1]; } return $ret; } } ?> I hope it helps someone ...

« previous php.notes (#107273) next »