I'm using str_replace("\n\n"); to find any two consecutive new lines \n but the problem is the text I'm working with isn't uniform. The new lines aren't aways back to back. They could be separated by any number of spaces or even a tab (found one). Don't like to use regex that much, but looks like I may need one here.
Try this:
$output = preg_replace('/\n\s*\n/s', '', $input);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With