TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Listing files and folders with scandir (http://www.talkphp.com/general/4913-listing-files-folders-scandir.html)

Jmz 08-29-2009 08:08 AM

Listing files and folders with scandir
 
I'm making a little script that will list the files and folders in a certain directory. Currently it looks like:

PHP Code:

<?php
//Scan the directory
$scan scandir("../www");

//Loop through the array
echo "<ul>";
foreach(
$scan as $key=>$value){
        echo 
"<li>".$value."</li>";
}
echo 
"</ul>";

Ideally I'd like to differentiate between what's a file and what's a folder. How would I do this?

TheOnly92 08-29-2009 10:05 AM

The function is_dir() will tell you if it is a directory.


All times are GMT. The time now is 07:35 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0