I want to read all files from this directory that are .htm and .html. How do I do that? I tried adding an asterix, but that doesn't work.
this is my code
<?php
$listdir = opendir ('/home/readir/'); while ($file = readdir ($listdir)) { if (preg_match('/.htm$/i', $file)) { echo "<a href = \"$file\">$file</a>"; print "<br>"; } } closedir ($listdir); ?>
$dir = "thedirectoryname";
$thisdir = dir($dir); while($entry = $thisdir->read()) { if(substr($entry, strlen($entry) - 4) == ".htm" || substr($entry, strlen($entry) - 5) == ".html" ) { // display } }
that's my way, quite simple but works. 😉