3
Good Morning I held the code below.
<?php
$diretorio = "../../arquivos/nest";
$ponteiro = opendir($diretorio);
while ($nome_itens = readdir($ponteiro)) {
$itens[] = $nome_itens;
}
sort($itens);
foreach ($itens as $listar) {
if ($listar!="." && $listar!=".."){
if (is_dir($listar)) {
$pastas[]=$listar;
} else{
$arquivos[]=$listar;
}
}
}
if ($pastas != "" ) {
foreach($pastas as $listar){
print "<img src='pasta.png'> <a href='$diretorio/$listar'download>$listar</a><br>";}
}
if ($arquivos != "") {
foreach($arquivos as $listar){
print "<a href='$diretorio/$listar' download>$listar</a><br>";}
}
?>
The Code works correctly, my doubt is. I want to create a variable that will have a specific text and that will serve as a filter to show the files you have in the directory with the variable in question.
Example: In the variable contain the information "Cars", when generating the listing only appear the files in the directories that have the file name "Cars".
This code there I think is from the site PHP Brazil. It’s a little outdated
– Wallace Maxters