Reply to Re: Foreach Loop with Nested Arrays

Your name:

Reply:


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
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация