Submitted by anonymous - 5 years ago
Remove blank lines
Removes all blank lines.
trim(preg_replace("/(^[\r\n]|[\r\n]+)[\s\t][\r\n]+/", "\n", $string));
You have replace with a newline char to break non-blank lines. This also leaves a single trailing newline, easily removed with trim($string); if needed.