Log in

View Full Version : Assign Images to an Array



itskimical
11-29-2010, 04:49 AM
How would I assign images to an array.

Here is my current array that I am working with


$group = array("Web Site", "E-Store", "Advanced", "Site Extras", "Administration");


Is there a way for me to say "instead of displaying the word "Web Site" display this image"?

I have access to the MYSQL database where the array is defined - if that makes a difference.

bluewalrus
11-29-2010, 05:17 AM
Something like


$figures = array("/thumbs/image1.jpg", "/thumbs/image2.jpg", "/thumbs/image3.jpg", "/thumbs/image4.jpg", "/thumbs/image5.jpg");

foreach ($figures as $figure) {
echo '<img src="' . $figure . '" alt="Figure" />' . "\n";
}

should do it. More info http://php.net/manual/en/control-structures.foreach.php