Re: echo?
| From: | Al | Date: | Tue, 22 Mar 2011 23:30:45 +0000 |
| Subject: | Re: echo? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311990@lists.php.net to get a copy of this message | ||
On 3/22/2011 6:22 PM, Jim Giner wrote:
Kinda new to this, but I've been puttering/writing for about 3 weeks now and have some good working screens up. Ran into something new while I was debuggina script today. Tried to echo the $i value within a for loop as part of the list of items I was building Something like for ($i=0;$i<$rows;$i++)If off your subject a bit; but, I suggest using $i=0; foreach($row as $value) { echo "$i $value<br />\n"; $i++; }echo $i.' '.$row['itemname'];I expected to see : 1 item1 2 item2 ... ... but instead I got 1 item1 f item2 Yes - an 'f' and not a 2. Tried it some more with this: for ($i=1;$i<10;$i++)echo $i." item".'<br>';and got c item d item e item f item g item .... and so on. It seems that I can only output the value of $i if I output a string in front of it echo ' '.$i; works fine but echo $i; does not. Any ideas?