动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 文件清单列表

作者来源: 
阅读 数 616 人次 , 2006-3-29 4:08:00 


[程序语言] php

[源码来源] http://px.sklar.com
[功能描述] 该脚本从一个指定目录中读取文件名,之后把这些文件名返回到数组中,还包括文件个数。

源代码如下:

<?
/*
this script read the filenames from a specified directory and returns them in an array.
the number of filenames is also returned.
copyleft(l) 1999 eric persson, eric@persson.tm, http://www.persson.tm/scripts/
*/
function searchdir($basedir)
{
global $filelisting, $number; //defines the two variables as global so they can be accessed from outside the function
unset($filelisting); //kills $filelisting in case it have been used earlier in the script
unset($number); //same as above
$handle=opendir($basedir);
while ($file = readdir($handle)) {
if ($file=="." or $file=="..") {
}
else {
$filelisting[]="$basedir$file";
};
};
$number=sizeof($filelisting); //gets the size of the array
};
searchdir("./"); //runs the function to search the current directory
echo $filelisting[1]; //echos the second value in the array
echo $number; //echos the size of the array
?>

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:PHP实现文件安全下载
· 下一篇:用PHP实现文件上传二法
· PHP脚本的8个技巧(1)
· PHP中如何Header出状态代码
· mysql方式操作文本数据库
· PHP 的编译配置详细选项
· mysql的用户变量


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077