Jump to content

get Directory/File info


tensuke

Recommended Posts

Check the manual:

[a href=\"http://www.php.net/dir\" target=\"_blank\"]http://www.php.net/dir[/a]

There is a lot of good info there. Especially the user comments at the bottom.

There are a couple of functions there that will return an array with all the file names and subdirectory names in an array that you can then do a count on to get the number of files in the directory.

To display the value of nearly any variable, you can use either echo or print.

[a href=\"http://www.php.net/echo\" target=\"_blank\"]http://www.php.net/echo[/a]
[a href=\"http://www.php.net/print\" target=\"_blank\"]http://www.php.net/print[/a]

For arrays, use the print_r function:

[a href=\"http://www.php.net/print_r\" target=\"_blank\"]http://www.php.net/print_r[/a]
Link to comment
https://forums.phpfreaks.com/topic/5458-get-directoryfile-info/#findComment-19537
Share on other sites

Thanks for the info,that helped. :D

EDIT:
Howdy,
I'm using
[code]
<?php
$dir = "/ipbfree";
$dh  = opendir($dir);
while (false !== ($filename = readdir($dh))) {
   $ipbfree[] = $filename;
}

echo count($ipbfree);
?>
[/code]
to scan the files in the directory ipbfree.Ipbfree is in the same folder as the index.html that is running the script.
But everytime I try to fix it,it doesn't display anything.The number is between [ ],and so it just shoes [].
I am using PHP 4.3.11.Any ideas?
Link to comment
https://forums.phpfreaks.com/topic/5458-get-directoryfile-info/#findComment-19561
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.