This php code uses opendir() to display an array of files in the folder.
Question: This code works as it is, but what i would like to do is display the description of the file as well.
I have added $description to the url in the code:
$result .= '<h6><a href="../folder/'.$file.'">'.$title.'</a></h6><p>$description</p><p><a href="../folder/'.$file.'">'.$file.'</a></p>';
which displays
File name
$description
file-name.php
Problem: I dont know how to call the function to get the description.
<?php
if ($handle = opendir('../folder/')) {
$fileTab = array();
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != 'index.php') {
$fileTab[] = $file;
}
}
closedir($handle);
shuffle($fileTab);
foreach($fileTab as $file) {
$title = str_replace('-', ' ', pathinfo($file, PATHINFO_FILENAME));
$result .= '<h6><a href="../folder/'.$file.'">'.$title.'</a></h6><p>$description</p><p><a href="../folder/'.$file.'">'.$file.'</a></p>';
}
}
?>
<?=$result?>