Dear programmers,
I have a form:
<form action=".." method="post">
<textarea name="text1"></textarea>
</form>
And a php file that saves this variable to a file:
$fp = fopen("file.txt ",a);
fwrite($fp,$_PO ST[text1]);
fclose($fp);
When I fill the textarea with the following text:
1,2,
3,
4.
In the file, the following appears (reading the file with Midnight
Commander on Linux):
1,2,^M
3,^M
^M
4.
In a new script, I want to parse this file. Every empty line should be
detected. How should I do that? if ($line == "\n") { .. } doesn't work,
because the line actualy contains ^M\n. When saving the contents of the
textarea to the file, I don't know how to strip the ^M characters.
Any ideas?
much thanks in advance!
Martin
(The Netherlands)
I have a form:
<form action=".." method="post">
<textarea name="text1"></textarea>
</form>
And a php file that saves this variable to a file:
$fp = fopen("file.txt ",a);
fwrite($fp,$_PO ST[text1]);
fclose($fp);
When I fill the textarea with the following text:
1,2,
3,
4.
In the file, the following appears (reading the file with Midnight
Commander on Linux):
1,2,^M
3,^M
^M
4.
In a new script, I want to parse this file. Every empty line should be
detected. How should I do that? if ($line == "\n") { .. } doesn't work,
because the line actualy contains ^M\n. When saving the contents of the
textarea to the file, I don't know how to strip the ^M characters.
Any ideas?
much thanks in advance!
Martin
(The Netherlands)
Comment