Re: How to remove new line character?

From: Date: Sun, 02 Nov 2003 18:54:05 +0000
Subject: Re: How to remove new line character?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-168342@lists.php.net to get a copy of this message
On Sunday 02 November 2003 11:50 am, Simon Stiefel wrote: > Sorry, one correction: > the 'chop()'-function only removes the whitespaces an the END of the > string. > > But if you want to remove the newline (and only this) at the end of the > string try this: > > $new_string = preg_replace("/\n$/", "", $old_string); To expand on the idea, make it capable of Windows and MAC new lines also $new_string = preg_replace("/\n|\r\n|\r$/", "", $old_string);

« previous php.general (#168342) next »