Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ghostchild

macrumors 6502
Original poster
Jun 17, 2007
355
0
Hey all so what I want to do is basically write a php code that pulls all my images from a certain folder filled with images and display them. Can someone write me a simple code that does that?

Thanks,
John
 
well im not looking for anything specific i just want to display the images.
 
Barebones (requires PHP5 or later):

PHP:
<?php

	$dir = "dir";
	$result = scandir ($dir);
	foreach ($result as $file) 
		{
			if (substr(strrchr($file, "."), 1) == "jpg")
					{
						echo "<img src=\"$file\">";
					}
		}
?>

Obviously you could modify it to scan for other image types, add links, etc.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.