LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-16-2012, 07:17 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
php opendir: sortling by name


Hi,

In a Php code, I would like to sort the files by name such as a, b... come first and z... last.


Would you know please what I should add below?

Code:
<?php
 if ($handle = opendir('.')) {
   while (false !== ($file = readdir($handle)))
 ...
thanks in advance !
 
Old 12-17-2012, 10:09 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
read the files in an array and then use one of the sorting functions for arrays like sort, asort, natsort,...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'opendir': No such file or directory. PsamtikNerd Linux - Software 2 10-01-2007 11:14 AM
opendir question nc3b Programming 6 07-30-2007 03:00 AM
c++ opendir() handling error bendeco13 Programming 1 11-06-2005 02:37 AM
opendir() SIGSEGV on RedHat 9 rylan76 Programming 2 05-26-2004 10:47 AM
perl opendir like function for php? paulish Programming 2 09-21-2003 03:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration