Re: Outputting Array Values
| From: | heinisch at creaction dot de | Date: | Tue, 09 Apr 2002 12:47:20 +0000 |
| Subject: | Re: Outputting Array Values | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92219@lists.php.net to get a copy of this message | ||
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 "<tr><td>Item " . ($n + 1) . " is $List[$n].</td></tr>"; You forgot the dot and the "echo "<tr><td>Item " . ($n + 1) . " is ".$List[$n]."</td></tr>";
} ?> <snip>