Try this, not sure if it will work though. I'm not all that good with arrays myself.
$dont = array(
$list => 'index.php',
$list .=> 'bar.php',
$list .=> '/somedirectory/',
);
$dir = "./";
$scandir = scandir($dir);
$scandir = array_slice($scandir, 2);
foreach ($scandir as $files) {
if(basename($files) == "{$dont[$list]}") {
continue;
}
$filesize = filesize($files);
$fsize = $filesize/1048576;
$fsize = round($fsize, 2);
echo '<li><a href="'.$files.'">'.$files.'</a> - ' .$fsize. ' MB</li>'."\n";
}