Jump to content

Get images and order them


vchris
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...