| 
	
 | 
 Posted by Jerry Stuckle on 06/14/07 18:15 
TSmith wrote: 
> Hey Y'all, 
>  
> I haven't programmed in PHP in quite a while. Could anyone help me 
> with a foreach loop in a nested array? I have a function which returns 
> $stock (for an online pricing catalog). 
>  
> $stock[0] is ( [0] => Item,  [1] => Sale,  ...) an array of column 
> headers. 
> $stock[1][$i] is ([Item] => SL,  [Sale] => 300, ...) an array of 
> column headers to value for item $i 
>  
> What I have to print the header row for the pricing table is: 
> print("<TR>"); 
> foreach ($stock[0] as $num => $val) { 
> 	print("<TH>" + $val + "</TH>"); 
> } 
> print("</TR>"); 
>  
> I've also tried ($stock[0] as $x) print($x). 
>  
> What returns is five zeroes. Not in table cells, just "<TR>00000</ 
> TR>". 
>  
> Does anyone have any ideas what I've done? 
>  
> Thank you in advance, 
> Taylor Smith 
>  
 
print("<TH>" + $val + "</TH>"); 
 
This is adding $val to two strings.  Rather, you need 
 
print("<TH>" . $val . "</TH>"); 
 
Or, you can even use: 
 
print("<TH>$val</TH>"); 
 
 
 
--  
================== 
Remove the "x" from my email address 
Jerry Stuckle 
JDS Computer Training Corp. 
jstucklex@attglobal.net 
==================
 
  
Navigation:
[Reply to this message] 
 |