Quick PHP Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Carlito
    Confirmed User
    • Dec 2001
    • 856

    #1

    Quick PHP Help

    I am working with a script that was written for me before, my PHP skills are virtually nonexistant and I need to edit the script to work multiple times on one page - I can't seem to do that with most standard functions.

    If someone could ICQ me or reply here and offer a suggestion, i`d be stoked.





    <?php


    define('MAX_FILES', 5);

    // changed below to save the path in a variable
    $dirpath = '.';

    $dp = opendir($dirpath);


    if ($dp) {

    while( $item = readdir($dp) )
    {

    if ( $item hahahaha '.' || $item hahahaha '..' )
    continue;

    // added this to skip files and only get dirs
    if (!is_dir($dirpath . '/' . $item))
    continue;

    // fixed error: path was not included
    // changed the way items were added to the array, not sure it was an error.
    if ($mtime = @filemtime($dirpath . '/' . $item))
    $all_files[$mtime][count($all_files[$mtime])] = $item;
    }
    krsort($all_files);
    foreach($all_files as $time=>$files)
    {
    for($i=0; $i < count($files); $i++)

    {
    $file = $files[$i];
    $date = date("m.d.y", $time);

    if (++$count > MAX_FILES)
    break;
    else {

    print <<<EOF

    EOF;



    }
    }

    }
    closedir($dp);
    unset($all_files);
    } else {
    print("Could not open directory.\n");
    }


    ?>



    At the moment if I use this code twice in a page, it never stops working from the first code, into the second.
  • Carlito
    Confirmed User
    • Dec 2001
    • 856

    #2
    blurb

    Comment

    Working...