Well, this is the kind of Way I would prefer to read and write the Array.
As you can see I am simply appending the new entry to the existing file. (In this case I tried to seperate the entry by using "/n")
<?php
// $NEW gets send per Get by the browser
$fnames = "names.txt";
$fp = fopen($fnames,"a+");
$Newnames = "\n".$NEW;
if (flock($fp, 2)) {
fwrite($fp, $Newnames, 100000);}
fclose( $fp );
?>
Now basically that works. I can load the array from the file using file() like this:
<?php
$fnames = file ('names.txt');
$i=0;
$ii=count($fnames);
for($i=0;$i<$ii;$i++){
echo "<option value=Si>",htmlspecialchars ($fnames[$i]);
}
?>
But the new entry merges with the last one before.
That means if I start of with an array like this:
Tom
Jill
James
and enter a new name ("Tim") with the script above, the array comes out like:
Tom
Jill
James/nTim
You see what I mean, the "\n" is simply not working as a seperator for entries in an array.
So I tried "\r", "\0" and so on, but it still doesn't work.
Is there a special ascii or other sign, to generate a linebreak that is valid for file(); ?
Hope I could explain the problem correctly
Thanks - Flunder