Programming Basics

  Home arrow Programming Basics arrow Page 2 - Reading Directorys with PHP
PROGRAMMING BASICS

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

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

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    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.
    blog comments powered by Disqus

    PROGRAMMING BASICS ARTICLES

    - Control Flow Constructs
    - More Time Manipulation with PHP
    - Validating and Manipulating Dates with PHP
    - Using the Date Constructor in PHP
    - Calendar Construction with PHP
    - PHP`s Calendar Package
    - Getting Modified Versions and Correct Dates ...
    - Combining Date Functions in PHP
    - Using PHP for Date and Time in Programming
    - More Exception Handling with PHP
    - Exception Handling in PHP
    - Error Logging and Handling Exceptions
    - Configuration Directives for Error and Excep...
    - Error and Exception Handling
    - Python Modules for Games


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap