Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19-06-2009
Member
 
Join Date: Jan 2009
Posts: 42
Show all files directories alphabetically with PHP

Show all files directories alphabetically with PHP, Is that possible? I need to list the files of a directory on my webpage. How do i do it? Please help me with the coding... I'm new to PHP... Thanks in advance...
Reply With Quote
  #2  
Old 19-06-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Show all files directories alphabetically with PHP

Well you must be clear with the basics first. I'm not sure but scandir function will do the work for you... All the best! If any problem, do post back!
Reply With Quote
  #3  
Old 19-06-2009
Member
 
Join Date: Jan 2009
Posts: 42
Re: Show all files directories alphabetically with PHP

Can you please help me with a sample code? May be i would be able to manipulate it with what i require.. Please help the noob...
Reply With Quote
  #4  
Old 19-06-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Show all files directories alphabetically with PHP

Here is a sample code :
Code:
<?php
$dir = "/tmp";
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}

sort($files);

print_r($files);

rsort($files);

print_r($files);

?>
Reply With Quote
  #5  
Old 19-06-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Show all files directories alphabetically with PHP

One more sample code :
Code:
<?php
$dir    = '/tmp';
$files1 = scandir($dir);
$files2 = scandir($dir, 1);

print_r($files1);
print_r($files2);
?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Show all files directories alphabetically with PHP"
Thread Thread Starter Forum Replies Last Post
How to transfer multiple files or directories Saura Technology & Internet 5 07-03-2010 03:19 AM
How to run dos2unix recursively on all files except under .svn/ directories Juaquine Software Development 4 09-02-2010 05:40 PM
Distinguishing between files and directories Flacos Software Development 3 05-12-2009 04:13 PM
List all Files and Directories in a Directory Samir_1 Software Development 0 08-12-2008 07:32 PM
How to Secure NTFS files and directories T.J. Tips & Tweaks 0 11-11-2008 02:26 PM


All times are GMT +5.5. The time now is 12:48 PM.