I'm trying to access a value via a non-numeric key and isn't working for me. I get the 'first letter' of the array everytime. I guess that my 'temp' variable is a scalar instead of an array... But, I don't understand how to fix this.
My situation: I'm gathering information out of my database (just a few values). Then, adding on one key=>value (seems to be fine). Then, when I try to access this data, no problem if I directly pull it out (for now, I have only one row). But, if I try to use foreach() or while(), I have the single letter issue. I can't understand why I should have to use mysql_fetch_array since I've already done that in my function (stored in a different document). Here's the print_r on my array, and the foreach that doesn't work, as well as the lines that do work (for a single row).
Code: Select all
Array ( [Product] => RS-WW-103 [Size]
=> between 8' x 5' - 12' x 6' [unitCost] => 650.00 [CompleteDesc] => Remodel - Stucco | Wood Window | between 8' x 5' - 12' x 6' [qty] => 5 )
//doesn't work
foreach($productInfoArray as $rowPrint){
echo $rowPrint["qty"]."<br><br>";
echo $rowPrint["CompleteDesc"]."<br><br>";
echo $rowPrint["unitCost"]."<br><br>";
}
//works fine, but only one row
$rowPrint = $productInfoArray;
echo $rowPrint["qty"]."<br><br>";
echo $rowPrint["CompleteDesc"]."<br><br>";
echo $rowPrint["unitCost"]."<br><br>";btw, my resulting printout (i've deleted some <br>'s for clarity) is:
R
R
b
b
b
6
6
6
R
R
R
5
5
5