Re: Getting rid of extra lines

From: Date: Wed, 29 Jul 2009 19:19:57 +0000
Subject: Re: Getting rid of extra lines
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-296020@lists.php.net to get a copy of this message
Miller, Terion wrote: > I am trying to get rid of empty whitespace lines, I can't us chop() because > as I read it it will remove all whitespaces....right? > > Right now my db is outputting with extra lines, I have stripped tags I know > it isn't that causing it to look like this > > Blahlajdlkfjlksdjflkdjsf > > <--------------how do I get rid of all this extra space? > > alkdfjlsdakjflsakdjflksjdf > > If the white space is included in data coming from the db you could run a simple little regex on the variable to removed any repetitive white space. But it might not be the best way to do it. $clean = preg_replace('|\s+|', ' ', $input); or $clean = preg_replace('|\s{2,}|', ' ', $input); If the white space is being generated in your HTML output, but is not in your data store, then you need to cleanup your PHP code and that might help.

« previous php.general (#296020) next »