Re: Removing empty array values.

From: Date: Mon, 18 Aug 2003 15:35:16 +0000
Subject: Re: Removing empty array values.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-159928@lists.php.net to get a copy of this message
* Thus wrote Johnson, Kirk (kjohnson@zootweb.com): > > On Mon, 18 Aug 2003 08:03:25 -0400, you wrote: > > > > >How do I remove empty array values? > > This will remove the empty values and re-index the array so there are no > "holes". > > $new_array = array_values($old_array); I wouldn't suggest this, it removes all your index's (renaming them to integers) plus it doesn't remove empty values. $array = array ("size" => "XL", "color" => "gold", 'blah'=>''); print_r(array_values ($array)); results: Array ( [0] => XL [1] => gold [2] => ) Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#159928) next »