Re: note 9068 added to trim

From: Date: Fri, 13 Oct 2000 18:41:03 +0000
Subject: Re: note 9068 added to trim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-6460@lists.php.net to get a copy of this message
At 06:25 PM 10/13/00 +0000, markus@frosch-digital.de wrote:
If you want shrink some whitespace to one from a string, you need to use this code:
$pizza  = "Teil1           Teil2         Teil3     Teil4 Teil5 Teil6             df";
$pieces = explode (" ", $pizza); $pizza = ""; while ( list(,$p) = each($pieces) ) {
    if ($p!="") { $pizza = $pizza . $p . " "; }
} $pizza = rtrim ($pizza);
Hi Markus, Thanks for the tip - however, there is a simpler way to do it:
$pizza  = "Teil1        Teil2    Teil3    Teil4 Teil5 Teil6      df\n";
$pizza = ereg_replace (' +', ' ', $pizza); --zak

« previous php.notes (#6460) next »