$line-out = str_replace('\r', '', str_replace('\n', '', $line-in));
The above works for me but, I saw a [\n\r] example somewhere and I cannot seem to find it.
I just want to get rid any blank lines. The above is in a foreach loop.
Thanks for teaching.
You shouldn't use - in variable names ;)
$line_out = preg_replace('/[\n\r]+/', '', $line_in);
$line_out = str_replace(array("\n", "\r"), '', $line_in);
Manual entries:
str_replace can be passed an array as:
$line_out = str_replace(array("\r","\n"), '', $line_in);
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