I have a php script that will echo a list of files from a folder and display them randomly on my page.
At the moment it displays the url of the file for example: what-can-cause-tooth-decay.php
i would like it to display the page title <title>What can cause tooth decay</title>
.
Current code:
<?php
if ($handle = opendir('health')) {
$fileTab = array();
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$fileTab[] = $file;
}
}
closedir($handle);
shuffle($fileTab);
foreach($fileTab as $file) {
$thelist .= '<p><a href="../health/'.$file.'">'.$file.'</a></p>';
}
}
?>
<?=$thelist?>
Many thanks