below is a script of images that are displayed from a folder on my server. i need to limit the images to 5. i want to add more images to the folder but i dont want all of them to be displayed. please help me limit. where and how do i do this?
http://www.jfleckpoetry.com/sharedphotos/recentphotos.php
<?php
$dir = 'images';
$file_display = array ('jpg');
if (file_exists ($dir) == false) {
echo 'Directory \'', $dir,'\' not found!';
} 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 style="height: 100px;" alt="" src="', $dir, '/', $file, '" alt="', $file, '">';
}
}
}
?>