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
https://forums.phpfreaks.com/topic/186260-where-to-add-sort/
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
https://forums.phpfreaks.com/topic/186260-where-to-add-sort/#findComment-983719
Share on other sites

Archived

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

×
×
  • 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.