Daily Archives: August 6, 2016

php -> get the list of files in a directory

Published by:

I wonder how to list a files in a directory with php lang. So I learn from php.net
here is the code, with various examples I made

<?php
$dir = "/opt/lampp/htdocs" ;
$files1 = scandir ($dir);
$files2 = scandir ($dir, 1);
$files3 = array_slice (scandir($dir),2);
echo $files1[5]; echo " ";
print_r($files3) ; echo " "; print_r($files1);
?>