Jump to content

Where to add sort


smordue

Recommended Posts

What and where do I add to sort the output of this alphabetically?

 

<?php
			 if ($handle = opendir('img')) {
			   while (false !== ($pics = readdir($handle)))
			      {
			          if ($pics != "." && $pics != "..")
				  {
						$picfile_x = substr($pics, 0, -4);
			          	$piclist .= '<li><img src="img/'.$pics.'" title="'.$picfile_x.'" alt="'.$picfile_x.'"/></li>';
			          }
			       }
			  closedir($handle);
			  }
			?>

 

Thanks!

Steve

Link to comment
Share on other sites

"$piclist .="

 

sort is an array function, You're outputting them as HTML in one string, you'll have to recode it to use sort() or work your own alphabetic sorting on the result. You can put them into an array beforehand, and echo " src=".imagepath[0]"/>"  or similar sorted..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.