0

I have currently displayed my images from a folder in my directory onto the screen using php, as shown below:

$file_display = array('jpg', 'jpeg', 'png', 'gif');

$dir = 'images';

if (file_exists($dir) == false)
{
    echo 'Doesnt exist';
}
else
{
    $dir_contents = scandir($dir);

    foreach ($dir_contents as $file)
    {
        $file_type = strtolower (end (explode('.', $file)));

        if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true)
        {
            echo '<img src="', $dir, '/', $file, '" alt="', $file,'" />';
        }  
    }
}

I have a set width of 600px for the screen size. I'm trying to display these images in 4 columns down the screen for now, and require the images to all be the same size.

Does anyone have any ideas on how to do this?

Ashwini Agarwal
  • 4,828
  • 2
  • 42
  • 59

1 Answers1

1

Try this:

echo '<img src="'.$dir.'/'.$file.'" alt="'.$file.'" width="600px" />';
Mani
  • 888
  • 6
  • 19
  • Thanks :) If i wanted to click on one of the images to display that full image in a pop-up window, how would i achieve this? – user2767270 Sep 11 '13 at 09:12