Hämta alla bilder i en mapp med glob

<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="fotogalleri.css">
<title>Foto Galleri</title>
</head>
<body>
<?php
$pics = glob('pics/*.jpg');
shuffle($pics);
$i=0;
foreach ($pics as $pic) {
  $i++;
  $imageinfo = getimagesize($pic);
  echo '<div class="box"  tabindex="'.$i.'">
          <div title="' . basename($pic,'.jpg') .'">
            <img src="' . $pic . '" alt="' . basename($pic,'.jpg') . '" width="' . $imageinfo[0]/2 . '" height="' . $imageinfo[1]/2 . '">
          </div>
        </div>';
}
?>
</body>
</html>