[nycphp-talk] Help with while loop
Scott Mattocks
scott at crisscott.com
Mon Nov 27 15:18:46 EST 2006
Randal Rust wrote:
> I have always had trouble with trying to write these from scratch. The
> code below is essentially what I have been working on, but it never
> stops looping. What am I missing here?
I am confused as to why you are looping over one value to begin with?
You really only need to loop over a list of values but you only have one.
Anyway, you need to change something with each iteration of your loop.
If you don't modify the team name, or the array of teams, or what
condition you are checking on you just keep checking the same thing over
and over and it always ends up with the same result (true in your case).
Every time you call checkDuplicate() you are resetting your count to 0.
You probably should be keeping that in a global somewhere so that it
keeps its value between iterations. But even then, I am not sure that
what you have written is what you really need.
--
Scott Mattocks
Author of: Pro PHP-GTK
http://www.crisscott.com
More information about the talk
mailing list