> read directory php ~ Online tutorial

read directory php

read directory php
<?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);
}?>
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




Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: