Jump to content

Get images and order them


vchris

Recommended Posts

I have a script that currently gets all the jpg files in a directory and then I sort them.

<?php$thumbslist = array();$counter = 0;$dir = "../images/websites";		$dh = opendir($dir);			while (($filename = readdir($dh)) !== false) {	if(strstr($filename, '.jpg')) { //images can only be jpg		$thumbslist[$counter] = $filename;		$counter++;	}}closedir($dh);			sort($thumbslist);			for($i = 0; $i <= count($thumbslist); $i++){	echo $thumbslist[$i].'<br />';}?>

Is there a way I could use to order them a certain way but that I could choose? It's always by groups of 2, 1 is small and the other is the large version.

Link to comment
Share on other sites

hmmm k but what about if the values are image file names. Those images are websites I've created, I want to order them by order of creation. I'm not sure how the user-defined sorting would work.edit: I found a way to sort by keys instead. This should work pretty good. I'll give it a try.http://ca.php.net/ksort

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...