Hi all - Pretty new to PHP and I hope there's a simple fix for this one.
What I'm trying to do is, while looping thru a mysql query results set, take selected values and pack them into an array - Each time through the loop I want to add another "row" to the array.

The following code snippet illustrates where I'm at so far:
//Array Tests
$FinalComparison[] = array("Column1Row1", "Column2Row1", "Column3Row1");
$FinalComparison[] = array("Column1Row2", "Column2Row2", "Column3Row2");
$FinalComparison[] = array("Column1Row3", "Column2Row3", "Column3Row3");
$count = count ($FinalComparison);
for ($i=0; $i<$count; $i++){
$countmore=count($FinalComparison[0]);
for ($j=0; $j < $countmore; $j++){
print ("---" . $FinalComparison[$i][$j]);
}
print "<br>";
}

It should produce this output:
---Column1Row1---Column2Row1---Column3Row1
---Column1Row2---Column2Row2---Column3Row2
---Column1Row3---Column2Row3---Column3Row3

What I'm after is this exact same scenario with one exception - the "$FinalComparison" array variable needs to be inside my loop, so I won't have to manually declare the array values as in the example. Any help is greatly appreciated!

    you don't need to do that redim crap in PHP, ASP has horrible array handling and if you need complex arrays, you need to use the ScriptingDictionary... ick

    check out [man]array_push[/man] or many of the other [man]array[/man] functions

      thanks for the help man - i'll check it out

        Write a Reply...