I would like to separate the html and just use echo for easier further styling/editing this html snippet, like this
<li>
<a href="<?php echo $filepath; ?>"><?php echo $file; ?></a>
</li>
Here is my current code that works, but I can not easily edit the html inside the PHP code
<?php
$dir = ".";
$exclude = array( ".","..",".*","*.php" );
if (is_dir($dir)) {
$files = scandir($dir);
foreach($files as $file){
if(!in_array($file,$exclude)){
$filepath = str_replace(' ', '%20', $file);
echo '<li><a href=' . $dir . '/' . $filepath . '>' . $file . '</a></li>';
}
}
}
?>