note 14619 deleted from function.next by jimw
| From: | jimw@php.net | Date: | Thu, 20 Dec 2001 22:09:31 +0000 |
| Subject: | note 14619 deleted from function.next by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23474@lists.php.net to get a copy of this message | ||
To handle an array of unknown size and put every second element into the right hand column of a
table I have done this:
/* Makes certain the array has an even value length. */
while( count($array)%2 != 0 ) $array[] = false;
while (list($key, $value) = each($array))
{
/* Put this value into the left column. */
print "Key: $key Value: $value";
/* Advances the pointer one. */
list($key, $value) = each($array);
/*
Put this value in the right hand column.
If $value == false you can add a " :"
so that the cell is left blank.
*/
print "Key: $key Value: ". $value ? $value : ' ' ;
}