Heim  >  Artikel  >  Backend-Entwicklung  >  如何能在php页面上显示服务器上文件名字

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

WBOY
WBOYOriginal
2016-06-13 13:44:22910Durchsuche

怎么能在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;
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn