Probably just something small, but I am using the below code to read the files inside of a directory and print them out as of a hyperlink to itself.
It prints out the complete file name, but it creates an incomplete hyperlink using only characters up to the first space. The question is how to create a functional hyperlink for a file with spaces in it?
$dir = '.';
$dh = opendir($dir);
$file_count = 0;
while (false !== ($file = readdir($dh))) {
$files[] = $file;
$file_count += 1;
echo $file;
}
for ($x = 0; $x < $file_count; $x += 1) {
echo "<a href=$files[$x]>" . "$files[$x]" . "</a><br>";
}