Ok I've got a script that opens all the .txt files in directory then reads them. It then stores it in a array then sorts the array and prints the variable in the "0" spot. My problem is that as soon as I combine the variables for the last part of its script journey all but the first letter gets lost. For example if the file contained "41" it would print "4". I no pretty much where the problem is which happens to be this part:
Code:
for ($nu = 0; $nu <= $num; $nu++)
{
$all[$nu] = "$buffer[$nu]$name[$nu]";
}
$buffer is the weird variable thats cutting its self. And now I realize you like to see the full sourcecode...
Code:
<?php
$num = 0;
chdir("pc");
foreach (glob("*.txt") as $filename) {
$num++;
$name[] = $filename;
}
$num--;
for ($nu = 0; $nu <= $num; $nu++)
{
if (!($fp = fopen($name[$nu], "r")))
exit("Unable to open the input file, $name[$nu].");
$buffer[$nu] = fread($fp, filesize($name[$nu]));
fclose($fp);
}
for ($nu = 0; $nu <= $num; $nu++)
{
$all[$nu] = "$buffer[$nu]$name[$nu]";
}
sort($all, SORT_NUMERIC);
rsort($all);
echo "$all[0]";
chdir("../");
?>
Does anyone see whats wrong and why it cuts? Please help....