Jump to content

Sorting number reversed problem...


Peuplarchie

Recommended Posts

Good day top you all,

            I'm working on a script that read a folder a list directory.

            The files in that folder are named by number, like 0 to 200.

   

          here how it would look like :

 

003

002

001

010

...

 

How can I make my list in complete reverse order like :

 

010

...

003

002

001

 

 

here is my code :

 

function listFilesInDir($start_dir)

        {
        
        /*
        returns an array of files in $start_dir (not recursive)
        */
                
        $files = array();
        $dir = opendir($start_dir);
$count =0;
        while(($myfile = readdir($dir)) !== false)
                {
                if($myfile != '.' && $myfile != '..' && !is_file($myfile) && $myfile != 'resource.frk' && !eregi('^Icon',$myfile) )
                        {
					$count = $count +1;	
                        $files[] = $myfile;
                        }
                }
        closedir($dir);
	rsort($files);
        return $files;


        }

Thanks !

 

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.