note 14619 added to function.next.php

From: Date: Mon, 06 Aug 2001 17:42:15 +0000
Subject: note 14619 added to function.next.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-16398@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 "&nbsp:" so that the cell is left blank. */ print "Key: $key Value: ". $value ? $value : ' ' ; } http://www.php.net/manual/en/function.next.php

« previous php.notes (#16398) next »