I want to write to a file that already has data in it. However when i do add the new data to the existing file it keeps going to where the filepointer last was (the end of the file) how can i get the file point to be in the 3rd line. Ive tried fseek and that just kept where the original filepointer was.
Any help is appreciatedrewind() resets the file pointer to the beginning, but i guess you want the third line. is the third line like in the middle and you want to change whatever is on that line? if so, you have to read the file into an array using file(). file() reads the file and splits it into an array based on newline characters.
$file = file("name of file");
then you change the third line by doing
$file[2] = "ASASAS";
then you have to join the array back together as one string using implode.
$file = implode("\n", $file);
and then you jsut right that to the file
Any help is appreciatedrewind() resets the file pointer to the beginning, but i guess you want the third line. is the third line like in the middle and you want to change whatever is on that line? if so, you have to read the file into an array using file(). file() reads the file and splits it into an array based on newline characters.
$file = file("name of file");
then you change the third line by doing
$file[2] = "ASASAS";
then you have to join the array back together as one string using implode.
$file = implode("\n", $file);
and then you jsut right that to the file