View Single Post

  #1 (permalink)  
Old 12-07-2006
studiobl
 
Posts: n/a
Default Variable Being Reset in For Loop

I'm trying to increment a variable in a for loop.

<---
$startColumn = 5;
for($rowLength = 0; $rowLength < $length; $rowLength++){
echo "New row current column : " . $startColumn . "<br />";
$startColumn++;
$newRow[$startRow][] = $startColumn;
echo "New row current column updated: " . $startColumn . "<br />"; }
--->

This outputs:

New row current column :5
New row current column updated:6

New row current column :5
New row current column updated:6...

Why is the $startColumn variable being reset to it's pre-loop value?
How can I increment this value?

Reply With Quote