Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Display a folder of images



It's exceedingly simple to process the files in a directory in PHP5.

http://www.php.net/scandir

If you're using an older version of php, you can find examples for it on the PHP site.

Here's a quick example using PHP5's technology. Please note that I included some file extensions that aren't really web images...

<?php
	// scan the files in the directory
	$directory = './images/';
	$files = scandir($directory);
	
	// process through each and add it to our document
	foreach($files as $file)
	{
		// look for an image file extension
		if ((strpos($file, '.jpg') > -1)	||
			(strpos($file, '.jpeg') > -1)	||
			(strpos($file, '.gif') > -1)	||
			(strpos($file, '.png') > -1)	||
			(strpos($file, '.tif') > -1)	||
			(strpos($file, '.tiff') > -1)	||
			(strpos($file, '.bmp') > -1))
		{
			// this is an image file
			echo '<img src="'.$directory.$file.'"><br>';
		}
	}
?>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden
References: 
 >Display a folder of images (From: Bill <email@hidden>)
 >Re: Display a folder of images (From: Errol Sayre <email@hidden>)
 >Re: Display a folder of images (From: Bill <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.