Directory difference question

Discussion in 'PHP' started by icfire, Dec 31, 2006.

  1. #1
    Ok,
    this works-
    http://www.puretricks.com/hi.php
    this doesn't work-
    http://www.puretricks.com/videos/hi.php

    The only difference is one is in a directory and one is not, here is the code-
    <?php
    if(!function_exists('scandir'))
    {
       function scandir($dir, $sortorder = 0)
       {
           if(is_dir($dir))
           {
               $dirlist = opendir($dir);
               
               while( ($file = readdir($dirlist)) !== false)
               {
                   if(!is_dir($file))
                   {
                       $files[] = $file;
                   }
               }
               
               ($sortorder == 0) ? asort($files) : arsort($files);
               
               return $files;
           }
           else
           {
           return FALSE;
           break;
           }
       }
    }
    function dirlist($dir) {
       foreach(scandir($dir) as $entry)
           if($entry != '.' && $entry != '..')
           {
               $entry  = $dir.'/'.$entry;
               
                   $path = pathinfo($entry);
                   $listarray[] = $path['basename'];
           }
       return($listarray);
    }
    
    
    $arr = dirlist("/kunden/homepages/15/d161670145/htdocs/__puretricks/videos");
    foreach ($arr as $value)
    {
    if (is_dir("/kunden/homepages/15/d161670145/htdocs/__puretricks/videos/".$value))
    {
    $value2 = preg_replace('/_/',' ',$value);
    echo $value2."<BR>";
    }
    }
    ?>
    PHP:

    Why?
     
    icfire, Dec 31, 2006 IP
  2. icfire

    icfire Peon

    Messages:
    321
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ok, I found out what works in both but now I am not sure how the previous code ever worked-

     
    icfire, Dec 31, 2006 IP
  3. GeorgeB.

    GeorgeB. Notable Member

    Messages:
    5,695
    Likes Received:
    288
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Define "doesn't work". Is there an error, no output/blank page?
     
    GeorgeB., Dec 31, 2006 IP
  4. icfire

    icfire Peon

    Messages:
    321
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There was no output
     
    icfire, Jan 1, 2007 IP