Welcome Guest, Not a member yet? Register   Sign In
Problems with sorting arrays returned by get_filenames()
#1

[eluser]swissbastian[/eluser]
Hi there

I got a problem with sorting arrays. The array is returned by the function get_filenames(). It looks like this:

Array ( [0] => 48.jpg [1] => 103.jpg [2] => 1.jpg [3] => 47.jpg [4] => 104.jpg [5] => 2.jpg [6] => 49.jpg [7] => 105.jpg [8] => 3.jpg [9] => 50.jpg [10] => 106.jpg [11] => 4.jpg [12] => 51.jpg [13] => 107.jpg [14] => 5.jpg [15] => 57.jpg [16] => 108.jpg )

Well, I don't know why the function puts the files in this order. It shouldn't be a problem when I sort the array. I've tried now several sorting functions (like sort, natsort, asort…) but I never worked.

Here's some code from the affected model:
Code:
$dateiliste_unsortiert = get_filenames('dateien/fotos/' . $album . '/');
        $dateiliste = natsort($dateiliste_unsortiert);
        
        foreach($dateiliste as $zeile) {
        
            $dateien[$zeile] = $zeile;
        
        }
        
           return $dateien;

Any idea what I'm doing wrong?


Messages In This Thread
Problems with sorting arrays returned by get_filenames() - by El Forum - 02-21-2008, 03:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB