Re: having trouble with is_file() and is_dir() on 5.1.2
| From: | jekillen | Date: | Tue, 23 Jan 2007 07:26:06 +0000 |
| Subject: | Re: having trouble with is_file() and is_dir() on 5.1.2 | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247612@lists.php.net to get a copy of this message | ||
On Jan 22, 2007, at 10:20 PM, Chris wrote:
jekillen wrote:Ok, I hope I can get this to work. The code I copied here was code that was in the directory reading loop, where I would have guess that it would have the path info, but it did the same thing. But I will take you suggestion. Thanks for the reply; JKHello 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++)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/{ 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]); } }