bm4499 Posted February 20, 2012 Share Posted February 20, 2012 Hi does anyone know how to sort the array below (files) echo "<br /><br /><b>Favorites</b><br />"; $d = dir("/mnt/disk/v1/mfiles/downloads/music/favorites/"); while (false !== ($entry = $d->read())) { if($entry!='.' && $entry!='..') { if(is_dir($entry)) { echo 'true'; $subdirs = get_leaf_dirs($entry); if ($subdirs) $array = asort(array_merge($array, $subdirs)); else $array[] = $entry; } echo '<a href="/scripts/download.php?actie=favorites/'.$entry.'" title="Click here to download this song" target="_blank">'.left($entry,(strlen($entry)-4)).'</a><br />'; } } $d->close(); Link to comment https://forums.phpfreaks.com/topic/257391-sorting-an-array/ Share on other sites More sharing options...
Psycho Posted February 20, 2012 Share Posted February 20, 2012 Sort it "how"? There are several functions for sorting arrays, the simplest of which is . . . drum-roll please . . . sort() Link to comment https://forums.phpfreaks.com/topic/257391-sorting-an-array/#findComment-1319256 Share on other sites More sharing options...
bm4499 Posted March 5, 2012 Author Share Posted March 5, 2012 i saw but tried some and did not get it work Link to comment https://forums.phpfreaks.com/topic/257391-sorting-an-array/#findComment-1324212 Share on other sites More sharing options...
ManiacDan Posted March 5, 2012 Share Posted March 5, 2012 Ok, you need to learn how to communicate a little better. You saw? You tried "some"? What are some? Some of the sorting functions? Why did you try them, and how did you do it? How did you determine they didn't work? What does "work" even mean to you? Did your computer catch fire? Did they come out in the wrong order? Did your monitor go blank? Maybe you can help me with my car while I'm here. It was making the noise, so I tried things, and they didn't work. Link to comment https://forums.phpfreaks.com/topic/257391-sorting-an-array/#findComment-1324214 Share on other sites More sharing options...
bm4499 Posted March 9, 2012 Author Share Posted March 9, 2012 sorry but u need to read better. I wrote I have tried some of those examples of php.net, especially for you asort, sort and so on. Stop answering questions with other questions. Just give a solution and don't waste our time any longer. The example of an unsorted array is given completely. Go read again. Link to comment https://forums.phpfreaks.com/topic/257391-sorting-an-array/#findComment-1325493 Share on other sites More sharing options...
ManiacDan Posted March 9, 2012 Share Posted March 9, 2012 The manual has all your answers, go read again. mod-edit: removed abusive language I never should have used Link to comment https://forums.phpfreaks.com/topic/257391-sorting-an-array/#findComment-1325494 Share on other sites More sharing options...
Recommended Posts