Jump to content

[SOLVED] foreach loop for 2 dimensional array?


unxposed

Recommended Posts

Hi, I've just turned my array into a 2 dimensional array, and it works great:

 

while ($row = mysql_fetch_assoc($result)) {
			$images_sub = array
    				(
       					'name' => $row['name'],
        				'description' => $row['description_' . $language],
    				);
   				$images[] = $images_sub;
		}

 

I'm now just struggling on how I'd now change my foreach loop to call the different variables:

 

foreach ($images as $image) {
	echo '<img src="$image['name']" alt="$image['description']" title="$image['description']" />';
}

 

Thanks in advance.

Oh god, yeah sorry it is! I'm not sure why it wasn't working for a minute there.

 

I don't suppose there's an easy way to only get the first set of values passed through the foreach loop, or get all but the first set of values?

 

Thanks, and sorry again.

i.e.

 

1. display $images[0] only in first foreach

2. display $images[1+] in second foreach (skip first values)

 

I need this as I'm putting the first set of values within different html from the rest (first image is displayed large, rest are thumbnails).

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.