php -> get the list of files in a directory

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);
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.