0
Hello. I have a table that should show the name of the files and the date they were updated, but nothing appears. In HTML I have only
<table><?php tabela("/arquivos/formularios/*.*"); ?></table>
And in PHP:
function tabela($var){
$globVar = glob($var);
for ($i=0; $i<count($globVar); $i++) {
$caminho = $globVar[$i];
if (file_exists($caminho)) {
$nome = basename($caminho,".*");
echo "<tr><td class=\"td1\"><a href=\"".$caminho."\">".$nome."</a></td>
<td class=\"td2\">".date("d/m/Y", filemtime($caminho))."</td></tr>";
}
}
}
When I load the page, I just see
<table></table>
Maybe I’m getting the glob() or other wrong function. I’d appreciate it if someone could help me.
Maybe the table input is wrong. Try
arquivos/formularios/*.*
relative path to script– gmsantos
That’s right, @gmsantos. Thank you!
– Dtag
Right after the line
$globVar = glob($var);
, try to display the values contained in the array using theprint_r
for example. Just to check if something is being returned from the functionglob()
.– Adriano Leal
Hi @Adrianoleal. It is. The problem was the same way. I do not understand very well the difference between the front or not. I will look it up later. Thank you
– Dtag
At least in Linux environment / demonstrates that you are searching from the root of your file system, i.e., root. Without using the / you search from the current directory of your application.
– Adriano Leal
It just keeps leaving the extension. basename() does not work with ".*"?
– Dtag
I know, I think we can make it explode()
– Dtag