I am new to PHP and for the sake of simplicity, I'll say that I am trying to create a crude website in which I want make an HTML table that checks the contents of an FTP folder and either adds a dot to the table if the target is found and an empty cell (w/ a  ) if not.
Here is my code and the folder structure:
<table border=1 >
<?php
foreach ($demolist as &$value) {
if($value != "." && $value != ".." && $value!=".DS_Store" ){
?> <tr> <?php
echo '<td> <a href="./layouts/'.$value.'/index.html'.'">'.$value.'</a </td>';
$png = $prezLayouts.$value;
echo $png.'<br>';
$sizeList = ftp_nlist($connection, $png);
natsort($sizeList);
foreach($sizeList as $target) {
if($target != "." &&
$target != ".." &&
$target !=".DS_Store" &&
$target != "index.html") {
echo $target."<br>";
if ($target == '640.png') { ?> <td> <?php echo "•"; ?> </td> <?php }
elseif ($target == '768.png') { ?> <td> <?php echo "•"; ?> </td> <?php }
elseif ($target == '1000.png') { ?> <td> <?php echo "•"; ?> </td> <?php }
elseif ($target == '1200.png') { ?> <td> <?php echo "•"; ?> </td> <?php }
else { ?> <td> <?php echo " "; ?> </td> <?php } ?>
<?php
}
}
?> </tr> <?php
}
}
?> </table>
OUTPUT from loop echo's
/domains/~~/html/demo/layouts/about
1000.png
1200.png
/domains/~~/html/demo/layouts/buy
640.png
768.png
/domains/~~/html/demo/layouts/contact
640.png
768.png
1000.png
1200.png
/domains/~~/html/demo/layouts/homepage
640.png
1000.png
1200.png
/domains/~~/html/demo/layouts/social
640.png
Now, my problem is that getting the list of the files in each folder won't let me check for files that don't exist in the folder. (doi) The only crude solution I can think of is creating a static array with [640.png, 768.png, 1000.png, 1200.png] and use that to check against the files in the folders, but I'm positive there is a more elegant solution.