View Single Post

  #11 (permalink)  
Old 05-08-2008
Iván Sánchez Ortega
 
Posts: n/a
Default Re: For loop question?

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!

foreach($cats[ $_GET['cat'] ] as $img) echo $img;


--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Reply With Quote