Programming Basics
  Home arrow Programming Basics arrow Page 2 - Reading Directorys with PHP
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PROGRAMMING BASICS

Reading Directorys with PHP
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-11-01

    Table of Contents:
  • Reading Directorys with PHP
  • The final code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Reading Directorys with PHP - The final code


    (Page 2 of 2 )

    <TABLE ALIGN=CENTER BGCOLOR=#ffffff CELLPADDING=4 CELLSPACING=0 border=2>
    <tr><TH>File</TH><TH>Size</TH></TR>
    <?php
      $dir="./";
      if (is_dir($dir)) {
        $fd = @opendir($dir);
        if($fd) {
          while (($part = @readdir($fd)) == true) {
            if ($part != "." && $part != "..") {
              $file_array[]=$part;
            }
          }
        }
        sort($file_array);
        reset($file_array);
        for($i=0;$i<count($file_array);$i++) {
          $npart=$file_array[$i];
          if (!strstr($npart,".inc.php") && !strstr($npart,"index.php")) {
            $fsize=filesize($npart)/1000;
            if (is_dir($npart)) {
              print("<tr><TD><a href=\"$npart\">$npart</a></TD><TD>Directory</TD></TR>\n");
            } else {
              print("<tr><TD><a href=\"$npart\">$npart</a></TD><TD>$fsize KB</TD></TR>\n");
            }
          }
        }
      }
    ?>

    </TABLE>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · just a couple of things that i did to get this excellent script to work for me.i...
       · I tried this code but I'm getting a parse error in the line...
       · I tried this code but I'm getting a parse error in the line...
       · what can i do to remove the file size
       · Instead display the dir result on table how can display the listing in a menu...
     

    PROGRAMMING BASICS ARTICLES

    - PHP: Hypertext Preprocessor: What is it?
    - Loops and PHP Decision Making
    - Operators, Conditionals, and PHP Decision-Ma...
    - PHP Decision-Making
    - Coding
    - Server Statistics
    - Looping in PHP
    - Cookies in PHP
    - Working with text files
    - Beginning Object Oriented Programming in PHP
    - A Tour of Decision Making Structures in PHP
    - PHP Strings Primer
    - PHP Control Structures
    - Intro to Vim
    - Reading Directorys with PHP





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek