-
In PHP3 how can I get the listings of a dir into an array?
I know it has something to do with readdir() and such, I just can't get the looping to work right.
Thanks,
-Matt
-
<?
$asdf = dir("whatever")
$ar = array();
while($file = readdir($asdf))
{
$ar[count($ar)-1] = $file;
}
?>
that should do the trick 
----------------------
my PHP host
-
Works like a charm!
Thank you very much,
-Matt
-
anytime.. glad to be of help 
----------------------
my PHP host -- your php host too!
-
Not to show you up, Vinay, but here's a slightly simpler version that works exactly the same. Could be faster for large directories.
<?
$asdf = dir("whatever");
$ar = array();
while($file = readdir($asdf))
{
$ar[] = $file;
}
?>
------------------
-Kevin Yank.
http://www.SitePoint.com/
Helping Small Business Grow Online!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks