Re: removing line breaks

From: Date: Fri, 05 Dec 2003 09:01:20 +0000
Subject: Re: removing line breaks
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171957@lists.php.net to get a copy of this message
On Fri, 2003-12-05 at 03:53, Roel Derckx wrote: > Hi > > I want to remove line breaks from the front of a string, but i can't get it > to work. Who can help me? > > The code i tried is: > while(substr($body,0,1)=="\n") $body=substr($body,1); > > i also tried: > while(substr($body,0,2)=="\n") $body=substr($body,2); > but this doesn't work either. This should work: $string = ereg_replace( "^[\n\r]+", '', $string ); Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#171957) next »