Der Inhalt des Txt-Files heißt natürlich:
$frucht[] = "Zitrone";
$frucht[] = "Apfel";
$frucht[] = "Banane";
$frucht[] = "Pflaume";
$frucht[] = "Birne";
Wie wärs damit:
<?
$fp=fopen('foo.txt','r+') or die('error opening foo.txt');
while(!feof($fp)) {
eval(fgets($fp));
}
sort($frucht);
rewind($fp);
while($item=array_shift($frucht)) {
fputs($fp,'$frucht[] = "'.$item.'";'."\n");
}
fclose($fp);
?>