Re: having trouble with is_file() and is_dir() on 5.1.2

From: Date: Tue, 23 Jan 2007 06:20:30 +0000
Subject: Re: having trouble with is_file() and is_dir() on 5.1.2
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-247603@lists.php.net to get a copy of this message
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/

« previous php.general (#247603) next »