note 59207 deleted from function.preg-replace by tularis

From: Date: Sun, 18 Jun 2006 13:28:38 +0000
Subject: note 59207 deleted from function.preg-replace by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114321@lists.php.net to get a copy of this message
Note Submitter: wcc at techmonkeys dot org ---- The previously-posted blank line removal code doesn't remove blank lines from the beginning of a string. This function is a solution. <?php /* * Removes all blank lines from a string. */ function removeEmptyLines($string) { $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string); $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string); return $string; } ?>

« previous php.notes (#114321) next »