I want to add a string (the value of a DOM element – $entry = stripslashes($_GET["nameofmytextarea"]);) to the second line of myfile.csv (so as not to delete the header).
I don’t care about CSV stuff, everything is already formatted. Just treat it as a text string being added to a text file.
I don’t want anything complicated, just skip the first line and “append” above the second line: under the header but above all the other CSV lines.
How hard can that be?
This should work if the lines are separated by unix-lineendings.
If the file first looks like this:
and the code is run with
$entry = 'test';it will look like this afterwards: