This is probably faster as:
```php
str_replace("\n", '', $str);
```