[PHP] Re: for loop inside a switch

2007-09-02 Thread M. Sokolewicz
jekillen wrote: On Aug 31, 2007, at 6:26 PM, Robert Cummings wrote: On Fri, 2007-08-31 at 15:56 -0700, Dan wrote: Sanjeev is right. You're thinking about the problem backwards. You're trying to build a Switch inside a loop. Remember, if you ever have to do some operating multiple times you

[PHP] Re: for loop inside a switch

2007-09-02 Thread Jonesy
On Fri, 31 Aug 2007 22:05:11 -0700, jekillen wrote: >You can run a switch inside a for loop and when a case is matched set >a variable to true. >the break statement will break out of the switch, then inside the >iteration code, after the switch block, test the variable for true. If >it is true

[PHP] Re: for loop inside a switch

2007-08-16 Thread Colin Guthrie
Stut wrote: > Hulf wrote: >> Hi, >> >> switch ($q) { >> >> for ($i=0; $i <21; $i++) { >> case 'faq$i': >> echo $faq1; >> break; >> } >> } >> >> >> I just want to loop out a big long list of cases. > > That's not a valid construct, but if I understand what you're trying do, > this should w

[PHP] Re: for loop inside a switch

2007-08-16 Thread Per Jessen
Hulf wrote: > Hi, > > switch ($q) { > > for ($i=0; $i <21; $i++) { > case 'faq$i': > echo $faq1; > break; > } > } > > > I just want to loop out a big long list of cases. You should look up "self-modifying code" - maybe in wikipedia. /Per Jessen -- PHP General Mailing List (http: