Re: [PHP] Outputting Array Values

2002-04-09 Thread heinisch

At 09.04.2002  08:33, you wrote:
That´s an easy on ;-)

Hello everyone!
I'm fairly new to PHP, but I do know JavaScript, which is both a blessing 
and a hinderance, as there are many syntax similarities, but a subtle 
amount of difference which means I usually screw something trivial up in 
my PHP code.  Can someone explain to me why the following isn't printing 
out each Array value?
?
$List = Array(Tomatoes, Onions, Carrots, Lettuce);
echo table border=1 bordercolor=white cellpadding=0 cellspacing=0;
for($n=0; $n  count($List); $n++)
{
   echo trtdItem  . ($n + 1) .  is $List[$n]./td/tr;
You forgot the dot and the 
echo trtdItem  . ($n + 1) .  is .$List[$n]./td/tr;
}

?
snip


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Outputting Array Values

2002-04-09 Thread Miguel Cruz

On Tue, 9 Apr 2002, Martin Clifford wrote:
   echo trtdItem  . ($n + 1) .  is $List[$n]./td/tr;

 It successfully prints out the following:
 
 Item Number 1 is .

 I just don't understand why it doesn't print out each value in the
 array... any help would be VERY appreciated!  Also, please CC me on any
 replies, as I'm subscribed to the digest!  Thanks!

If you put an array dereference inside a literal string, you have to 
surround the whole assembly with curly braces, thusly:

echo trtdItem  . ($n + 1) .  is {$List[$n]}./td/tr;

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php