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're using a forloop, then the thing that
> you want to repeat(swi
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're using a forloop, then the thing that
you want to repeat(switch case) is INSIDE the for loop.
- Dan
""Sanjeev N
This will not work at all..
Instead of switch try with if condition as follows
for ($i=0; $i <21; $i++) {
if(faq$i == $q){
echo $faq1;
break;
}
}
Now it works..
You can write the code to display the result how you want.. but you cant
write the code to write
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.
are the case's that you want to create with the loop going to be the only case
statements in the switch?
--
Jim Lucas
"Some men are
On 8/16/07, Hulf <[EMAIL PROTECTED]> 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.
Maybe you want this kind of functionality :
http://www.php.net/manual/en/language.varia
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 work...
$faqs = array();
for ($i = 0; $i < 21; $i+
I don't think it is going to work. IMO
On 8/16/07, Hulf <[EMAIL PROTECTED]> 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.
>
> --
> PHP General Mailing List (http://www.p
7 matches
Mail list logo