Re: [PHP] while-do +array
- From: robinv@xxxxxxxxx ("Robin Vickery")
- Date: Wed, 31 Oct 2007 15:25:03 +0000
On 31/10/2007, Steven Macintyre <steven@xxxxxxxxxxxxxxxxxxxxx> wrote:
Hiya,
I have the following code ... which only seems to result in one item ...
which is incorrect ... can anyone spot my problem?
if ($armbase != "") {
$options = explode(",", $armbase);
$text .= '<table ><tr>';
$get_endRow = 0;
$get_columns = 8;
$get_hloopRow1 = 0;
do {
if($get_endRow == 0 && $get_hloopRow1++ != 0) {
$text .= '<tr>';
$text .= '<td valign="top" width="60">';
$text .= "<img
src='".e_BASE."images/options/armbase/".$value."'>";
$text .= '</td>';
$get_endRow++;
}
if($get_endRow >= $get_columns) {
$text .= '</tr>';
$get_endRow = 0;
}
} while(list($key,$value) = each($options));
The first time around the loop, both $key and $value are undefined, as
you're not setting them until the end condition.
But that's not a big deal as nothing gets done first time through the
loop except for $get_hloopRow1 getting incremented.
The next time through the loop, because $get_hloopRow1 is now not
zero, the first conditional gets executed. You add some html and the
first value from the array to $text to the string and incremenent
$get_endRow.
All subsequent times through the loop, nothing gets done because the
$get_endRow == 0 condition fails. $get_endRow never gets incrememented
again.
that help at all?
-robin
.
- References:
- while-do +array
- From: "Steven Macintyre"
- while-do +array
- Prev by Date: Re: [PHP] FW: Reaching the PHP mailing list owners
- Next by Date: Re: [PHP] Re: docs.google.com how do the export ?
- Previous by thread: RE: [PHP] while-do +array
- Next by thread: RE: [PHP] Stopping objects from auto-serializing
- Index(es):
Relevant Pages
|