franzwarning Posted March 23, 2011 Share Posted March 23, 2011 Here is my current code to display files from the end to beginning : <?php function func() { $date = date("Y-m-d"); $picarray = array(); $userarray = array(); $handle = opendir ('pqimages/'.$date.'/'); while (false !==($file = readdir($handle))) { if($file != "." && $file != "..") { $picarray[] = "http://blah.com/pqimages/".$date."/".$file.""; $userarray[]= "pqimages/".$date."/".$file.""; } } sort($picarray); sort($userarray); closedir($handle); $json_array = json_encode($picarray); echo $json_array; } func(); ?> How could I change this from end to beginning for ($picarray)? Cheers, George Link to comment https://forums.phpfreaks.com/topic/231543-display-files-in-array-from-end-to-beginning/ Share on other sites More sharing options...
DavidAM Posted March 23, 2011 Share Posted March 23, 2011 Try rsort() instead of sort()? Link to comment https://forums.phpfreaks.com/topic/231543-display-files-in-array-from-end-to-beginning/#findComment-1191496 Share on other sites More sharing options...
Maq Posted March 23, 2011 Share Posted March 23, 2011 Next time you post in the wrong section just click on "Report to Moderator" and one of us will move your thread to the appropriate section. Do not double post. Link to comment https://forums.phpfreaks.com/topic/231543-display-files-in-array-from-end-to-beginning/#findComment-1191497 Share on other sites More sharing options...
Pikachu2000 Posted March 23, 2011 Share Posted March 23, 2011 array_reverse() Link to comment https://forums.phpfreaks.com/topic/231543-display-files-in-array-from-end-to-beginning/#findComment-1191514 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.