<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Show random image in PHP'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Sat, 25 May 2013 06:52:01 GMT</pubDate>
<item>
<title>Grandmaster said on 10/7/10</title>
<link>http://snipplr.com/view/41709/show-random-image-in-php/</link>
<description><![CDATA[ # my solution, think it's better and has extension check

$dir = 'i';
$img_ext = array('jpg', 'jpeg', 'gif', 'png');
$images = array();
if($handle = opendir($dir)) {
	while (false !== ($file = readdir($handle))) {
		$info = pathinfo($dir.'/'.$file);
		if(in_array($info['extension'], $img_ext)) {		
			$images[] = $file;
			}
	}

    closedir($handle);
}

$random = array_rand($images);
echo $images[$random]; ]]></description>
<pubDate>Thu, 07 Oct 2010 17:46:16 GMT</pubDate>
<guid>http://snipplr.com/view/41709/show-random-image-in-php/</guid>
</item>
<item>
<title>Grandmaster said on 10/7/10</title>
<link>http://snipplr.com/view/41709/show-random-image-in-php/</link>
<description><![CDATA[ # my solution, think it's better and has extension check

$dir = 'i';
$img_ext = array('jpg', 'jpeg', 'gif', 'png');
$images = array();
if($handle = opendir($dir)) {
	while (false !== ($file = readdir($handle))) {
		$info = pathinfo($dir.'/'.$file);
		if(in_array($info['extension'], $img_ext)) {		
			$images[] = $file;
			}
	}

    closedir($handle);
}

$random = array_rand($images);
echo $images[$random]; ]]></description>
<pubDate>Thu, 07 Oct 2010 17:43:51 GMT</pubDate>
<guid>http://snipplr.com/view/41709/show-random-image-in-php/</guid>
</item>
</channel>
</rss>