random image from an array PHP5
<p>This array is being created correctly, although i need to pick one then print it which isnt happening for me...any ideas?</p>

<pre><code>&lt;?php
$bgimagearray = array();
$iterator = new DirectoryIterator("/home/sites/yellostudio.co.uk/public_html/public/themes/yello/images/backgrounds");
foreach ($iterator as $fileinfo) {
    if ($fileinfo-&gt;isFile() &amp;&amp; !preg_match('/-c\.jpg$/', $fileinfo-&gt;getFilename())) {
        $bgimagearray[] = "'" . $fileinfo-&gt;getFilename() . "'";
    }
}

$bgimage = array_rand  ( $bgimagearray, 2 );


?&gt;
&lt;img src="&lt;?php echo URL_PUBLIC; ?&gt;public/themes/yello/images/backgrounds/&lt;?php echo $bgimage; ?&gt;" alt=""/&gt;
</code></pre>
