2
I need to read a directory and change its icons. If it is a directory, apply an icon if it is a file. txt apply another icon.
Follow the code I made:
<?php
$dir = 'ftp/';
$pasta = opendir($dir);
while ($arquivo = readdir($pasta)){
// Caso o arquivo tenho '.' identificaria como .txt
if ($arquivo = '.' ){
echo "<img src='../img/pasta.ico'>";
} else {
echo "<img src='../img/archive.ico'>";
}
}
?>
I forgot to add the '}' to close the while.
– Vinícius
There are programming errors, one of them would be
$arquivo =
ta missing one more equal, because, comparison are two or three:$arquivo ==
or$arquivo ===
(with three plus compare value compares type)– user6026
Didn’t work out my version?
– Jorge B.
It worked Jorge B. Thank you. But Junior’s answer was more satisfactory.
– Vinícius