note 63791 added to function.php-strip-whitespace

From: Date: Thu, 30 Mar 2006 22:31:47 +0000
Subject: note 63791 added to function.php-strip-whitespace
Groups: php.notes 
Request: Send a blank email to php-notes+get-107052@lists.php.net to get a copy of this message
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 ... ---- Server IP: 66.163.161.117 Probable Submitter: 200.107.3.5 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.php-strip-whitespace.php Edit -- http://master.php.net/note/edit/63791 Del: integrated -- http://master.php.net/note/delete/63791/integrated Del: useless -- http://master.php.net/note/delete/63791/useless Del: bad code -- http://master.php.net/note/delete/63791/bad+code Del: spam -- http://master.php.net/note/delete/63791/spam Del: non-english -- http://master.php.net/note/delete/63791/non-english Del: in docs -- http://master.php.net/note/delete/63791/in+docs Del: other reasons-- http://master.php.net/note/delete/63791 Reject -- http://master.php.net/note/reject/63791 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107052) next »