jekillen wrote:
Hello php developers:
I am having a problem with the following code:
OS: FreeBSD v6.0
Apache 1.3.34
php 5.1.2
-> $cont is an array produced from opening and reading a
directory:
for($i = 0; $i < count($cont); $i++)
     {
       print $cont[$i].'<br>';
        if(is_file($cont[$i]))
          {
             print "is file: ".$cont[$i].'<br>';
             //array_push($files, $cont[$i]);
            }
       else if(is_dir($cont[$i]))
            {
                print "is dir: ".$cont[$i]."<br>";
                 //array_push($dirs, $cont[$i]);
             }
      }


I'd be guessing it's a path issue.

Try prefixing the is_dir and is_file calls with the path to the directory they are in:

$basedir = '/whatever';

for($i = 0; $i < count($cont); $i++) {
  $fullpath = $basedir . '/' . $cont[$i];
  if (is_file($fullpath)) {
  .....
}

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to