Raj Shekhar wrote:
"M. Sokolewicz" <tularis@xxxxxxx> writes:
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 work
{
echo "On last element";
break;
}
else
{
echo "Somwhere in the middle";
}
}
that's an eternal loop in case you hadn't noticed (*rolls eyes*)
Oops :( not eternal loop though, only one loop
why one?
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? :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php