<?php if ($handle = opendir('.')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." ) { echo "$entry\n"."<br>"; } } closedir($handle); } ?> How to make so that only .html files are viewed?
<?php if ($handle = opendir('.')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." ) { echo "$entry\n"."<br>"; } } closedir($handle); } ?> How to make so that only .html files are viewed?
For these purposes, you can use the glob() function, which provides a search for files by a given mask.
<?php foreach (glob("*.html") as $filename) { echo "$filename\n<br>"; } If you also need to specify the directory to search for (in addition to the current one), then also specify it in the search mask, for example, glob("/var/log/*.log") .
rename() , whose parameters are the current file name, and a new one. - teranTake a look at the SPL, there you can find a lot of ready-made solutions.
<?php foreach (new DirectoryIterator('.') as $fileInfo) { if (!$fileInfo->isDot()) continue; if ($fileInfo->getExtension() == 'html') { echo $fileInfo->getFilename() . "\n"; } } isDir() check in the first condition? - teran 2:51Source: https://ru.stackoverflow.com/questions/595429/
All Articles
glob("*.html")- teranhtmlto what you already have with.and..- teran 2:41