read directory php
Output:
index.html
est.html
first.php
Explanation
Now opendir simply opens a directory,replace folder with the name of the folder and if needed, the path too.The while loop then goes through file by file in the directory .the if statement exclude s showing two non-files.you can exclude any files you wish too.After a simpl e echo displaying the filename
<?php // assign folder into variable $currdir='/var/www'; //open the directory for reading $dir=opendir($currdir); //read a filename while($file = readdir($dir) { // Display all file name in the specified folder echo "$file<br/>"; } closedir($dir); }?> |
index.html
est.html
first.php
Explanation
Now opendir simply opens a directory,replace folder with the name of the folder and if needed, the path too.The while loop then goes through file by file in the directory .the if statement exclude s showing two non-files.you can exclude any files you wish too.After a simpl e echo displaying the filename
0 comments:
Post a Comment