Selecting random photos from featured album, PHP
<p>Greetings,</p>

<p>I am adding four random photos from a featured photo album to the front page of a site in the form of a jQuery photo slider. Since all of the images must be the same size, I select only horizontal photos, shuffle them, and then trim that down to 4. Here is the code I am using. My question - is there a simpler, perhaps more efficient way to do this? Or is my method fairly sound?</p>

<p>Thanks!</p>

<pre><code>$getImages = $gallery_db-&gt;query("SELECT * FROM images WHERE album = '5'"); //sample SQL
$imagesArr = array();
while ($image = $getImages-&gt;fetch()) {
    $path = "http://somewhere.com/gallery/photos/" .
 $image['album'] . "/" . $image['filename'] . ".jpg"; //All files are .jpg
        list ($width, $height) = getimagesize($path);
        if ($width &gt; $height) {
            $imagesArr[] = $path;
        }
    }
    shuffle($imagesArr);
    array_splice($imagesArr, 4)
</code></pre>

<p>and then, to output:</p>

<pre><code>foreach ($imagesArr as $path) {
        echo "&lt;img src=\"$path\" width=\"220\" height=\"110\"/&gt;&lt;br/&gt;\n";
    }
</code></pre>
