Re: end of array
| From: | M. Sokolewicz | Date: | Sat, 22 Jan 2005 18:23:41 +0000 |
| Subject: | Re: end of array | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207046@lists.php.net to get a copy of this message | ||
Raj Shekhar wrote:
"M. Sokolewicz" <tularis@php.net> writes:for($i=0; $i<$n;$i++) { $i = ($n-1); } to me that means the following: 1. check if $i<$n; true! ($i=0; $n>1) 2. $i=$n-1, this means that $i<$n (less by 1 in fact) 3. check if $i<$n; true! ($i=$n-1; $n>$i by definition) 4. $i is reset to $n-1 5-eternity. conditions are met, and var is reset or am I missing something here? :)Raj Shekhar wrote:$n_elts = count($myarray); for ($i=0; $i< $n_elts ; $i++) {if ($i = $n_elts -1)^^^ Use of == required to make it workOops :( not eternal loop though, only one loop why one?that's an eternal loop in case you hadn't noticed (*rolls eyes*){ echo "On last element"; break; } else { echo "Somwhere in the middle"; }}