Re: Empty elements in array

From: Date: Tue, 01 Aug 2000 06:45:53 +0000
Subject: Re: Empty elements in array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-9364@lists.php.net to get a copy of this message
On 1 Aug, Noor Dawod wrote: > Why the comma before $v in the example below? > > Noor > > -----Original Message----- > Subject: Re: [PHP] Empty elements in array > > >> I have five elements in an array, and I have a while loop acting on the >> array. However, I only want the non-empty elements to be processed by the >> while loop - how do I tell it to ignore the empty elements? >> >> Thanks in advance for any help... :o) > > while(list(,$v)=each($array)) { > if($v) { > do something > } > } > > -Rasmus > Well, to do a Richard Lynch wild guess:-) Assuming that the array is one dimensional, list will return the key and value for each element of array. If you don't want the key, don't assign it to a value, but there must be the correct number of arguments separated by commas. I don't think that's as clear on the terminal as it is to me - hope it makes sense. Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#9364) next »