CoderZone.org

Category: >> PHP Code >> Remove empty lines from text files Bookmark and Share

<< lastnext >>

Snippet Name: Remove empty lines from text files

Description: Compact function that strips (removes) empty lines from text files or strings. Useful for cleaning up user input.

Also see:
» Strip Comments From Code
» Remove empty lines from a string o...
» Add and Remove classes in Javascri...
» Create an array from the lines of ...
» Remove Duplicate Lines from a File
» Confiurable "Wrap Lines" Function
» Dynamically add and remove elements
» Remove Extra Spaces From A String
» Dynamically Add/Remove rows in HTM...
» Remove Duplicate Lines from a File
» Remove all non-ASCII chars
» Remove Duplicates
» Remove extra linebreaks
» Improved Strip_Tags()
» Strip HTML to Text
» Add/Remove from Select list
» Count lines in file
» Set/Get/Remove Cookies
» Remove All Files An A Given Direct...
» Strip all non-alphanumeric charact...
» Shorten URLs for a cleaner appeara...

Comment: (none)

Author:
Language: PHP
Highlight Mode: PHP
Last Modified: December 31st, 2010

function removeEmptyLines($string){
   return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);
}
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 8