Well I'ts because you are wrong ina your array loops. U have two arrays, one whith file names, another with file sizes, and make loops like this
foreach(filenames){
foreach(filesizes){
......
}
}
on each filename iteration you have count(filesizes) iteretions, this code will work fine for your solution
foreach ($Files as $idx => $File){ # Loop through each entry in the Files array.
$SizeM=$FileSize[$idx];
$File = explode('.', $File); # Ok, lets split the full name into an array....
$FileM = $File[0]; # Ok, we want the first secion for the file name.
if (count($File) > 1){ # Check length of File...
$Extension = "." . $File[1]; # Ok, we not want the extension which is the second part of the string.
if ($Extension != ".htaccess"){ # Is the file a .htaccess file?
echo "<li>$FileM$Extension:<ul><li>File Name: [$FileM]</li><li>Extension: [$Extension]</li><li>Size: [$SizeM Kilo-bytes]</li></ul></li>\n"; # No, Ok print the results...
}
else{
echo "<li>.httaccess:<ul><li>File Name: [.httaccess]</li><li>Extension: [None]</li><li>Size: [$SizeM Kilo-bytes]</li></ul></li>\n"; # Yes, .htaccess needs special treatment.
}
}
else{
echo "<li>$FileM$Extension:<ul><li>File Name: [$FileM]</li><li>Extension: [$Extension]</li><li>Size: [$SizeM Kilo-bytes]</li></ul></li>\n"; # More output.
}
}
but any way, you have the bad coding style, better to make one 2 level array:
$Files[0]['FileName']
$Files[0]['FileSize']
$Files[0]['FileType']
$Files[1]['FileName']
$Files[1]['FileSize']
$Files[1]['FileType']
and also, what I found, not all extensions are going after first point, e.g. file with name like
supa-year-1912.12.12.doc
will have supa-year-1912 name only and doc as extension - a middle part of file will lost. you have to find anothe one solution.