Without access to a MySQL database, I am writing to and reading from a text file for a simple CMS.
My problem lies in transferring text from a textarea input form to the tab delimited text file. Because my description field is so long and will consist of paragraphs, meaning people will be hitting "Enter" or "Return" a lot, this wreaks havoc with my tab delimited file for some reason.
I have tried many solutions. I have tried nl2br(), and this places <br>'s where there are \n's, but in the text file everywhere "Enter" was hit, there is a new line in the file.
I even tried using a "|" as the delimeter but this produced the same effect.
Some code:
<?php
$TheFile = "data/{$_POST['file']}.txt";
$Open = fopen ("$TheFile", "w");
if ($Open) {
fwrite ($Open, "{$_POST['headline']}|{$_POST['desc']}");
fclose ($Open);
} else {
echo "Error!";
?>
It's very simple yet it's driving me insane. I have three form fields, 'file', 'header' and 'desc'. The above code is in my handlform.php file.
I even tried photomatt's autop function and it did the same as described above. What is causing my newlines to stick around?