File Manipulation Code

  Home arrow File Manipulation Code arrow a class to Get and Output Directories ...
FILE MANIPULATION CODE

a class to Get and Output Directories List
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    A framework to get the directories list at a given path and possibly print it, core or as ht-links to each directory (useful if each contains an index.htm for ex)

    By : llgdholland

    <?php
    class dirList
    {

    var $oa_names; //array containing names
    var $length;


    function getLength ()
    {
    return $this->length;
    }
    function setLength ($fa_l)
    {
    $this->length=$fa_l;
    }


    function sortList ()
    {
    sort($this->oa_names);
    }

    function printListKey ($fa_key) //print array element corresponding to a given key
    {
    echo $this->oa_names[$fa_key];
    }

    function printListKeyLink ($fa_key)
    {
    echo "<a href=\"".$this->oa_names[$fa_key]."\">".$this->oa_names[$fa_key]."</a>";
    }


    function printList ()
    {
    reset ($this->oa_names);
    while (list ($key, $val) = each ($this->oa_names))
    {
    echo $val;
    echo "<br>";
    }
    }
    function printListLink ()
    {
    reset ($this->oa_names);
    while (list ($key, $val) = each ($this->oa_names))
    {
    echo "<a href=\"$val\">$val</a>".$key;
    echo "<br>";
    }
    }

    function dirList ($fa_path='.')
    {
    $dr = dir($fa_path);
    //compteur
    $i=0;
    while($entry=$dr->read())
    {
    if (is_dir($entry) && ($entry!=".") && ($entry!=".."))
    {
    $this->oa_names[$i]=$entry;
    $i++;
    }
    }
    $this->setLength($i);
    if ($i>0)
    {
    $this->sortList();
    }
    }
    }
    ?>
    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.

    More File Manipulation Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    FILE MANIPULATION CODE ARTICLES

    - Bandwidth Control with pure PHP
    - Eazy Gallery
    - file_get_contents for PHP < 4.3.0
    - PHP Class: Image Snapshot 1.3
    - Universal downloader
    - Image Gallery v2.0
    - Free/Used Disk Space
    - Directory Lister
    - Directory image view, with selective hidden
    - Move or Copy a Directory (and files and sub ...
    - Ensure_Sub_Directory_Exists
    - Wedit
    - Form Examples Text Boxes to Drop Downs
    - myFiles
    - List files in a directory, no subdirectories


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