Re: For loop question?
On Thu, 08 May 2008 23:14:44 +0200, Iván Sánchez Ortega
<ivansanchez-alg@rroba-escomposlinux.-.punto.-.org> wrote:
> Rik Wasmus wrote:
>
>> The correct way to do this is:
>>
>> $cats = array(
>> 1 => array('moonlight.jpg' .......),
>> 2 => array(....),
>> 3 => array(....));
>
> An alternate way to do the same is:
>
> $cats[1] = array('moonlight.jpg' .......);
> $cats[2] = array('foobar' .......);
> $cats[3] = array(...);
>
>> And then just use:
>>
>> foreach($cats[$_GET['cat'] as $img) echo $img;
>
> You're missing a "]" here, Rik!
Oh no! Now all I say is suspect, and therefor should not be followed.
Forget what I said, having $cat_1 & $cat_2 like variable names must be a
great idea :).
--
Rik Wasmus
|