Home >Backend Development >PHP Tutorial > 如何能在php页面上显示服务器上文件名字

如何能在php页面上显示服务器上文件名字

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 13:44:22979browse

怎么能在php页面上显示服务器上文件名字?
我想把linux系统下home文件夹下的文件显示到php页面上,能按照时间、文件大小排序 实现查看文件的效果

举个例子:

  $test = "ls /tmp/test"; //ls是linux下的查目录,文件的命令

  exec($test,$array); //执行命令

  print_r($array);

  ?>
排序的我没想到
  请问我得怎么写

------解决方案--------------------
scandir的第二个参数可以指定按文件字母顺序 排序

或者你用命令 ls -lnt ls -lrt按时间顺序显示
------解决方案--------------------

PHP code

$data=glob("/usr/local/apache/*");//数据在这里

$table = '
'; $count = count($data);//表格总数 $col = 3;//列数,此处可以设置 for ($i = 0; $i  '; } else{ $table .= ''; } if($i%$col == $col-1){ $table .= ''; } } if ($count%$col != 0){ for ($i = 0; $i  '; } $table .= ''; } $table .= '
'.$data[$i].'
'; echo $table;
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn