PHP Display files in directory with .html extension?

<?php
if(!$handle = opendir( "directory/path" )) {
echo "Cannot open directory.";
else {
while(false !== ($file = readdir($handle))) {
if(strpos($file, ".html") !== false || strpos($file, ".php") !== false) {
echo "$file<br>";
}
}
}
closedir($handle);
?>
 
why are you doing .html/.php?

simply .php is able to do both...

for instance:

<?php

for( $n = 0; $n < 4; $n++ ) {
if( $n == 0 || $n ==2 ){
?><p>Hello World</p><?php
}
if( $n == 1 || $n == 3 ){
?><p>Hi Low</p><?php
}
}

?>
 
Back
Top