Well here is the problem...
I am getting a string from a textarea box in a form.
I want to put that string inside a javascript file (js) to define a variable like this:
var text = "text from form";
BUT! if the user types a newline inside the textarea box(just by hitting "enter"), the javascript file ends like this:
var text = "text
from form";
(not a single line)
Solution? This code before sending to the file:
$res = ereg_replace("\n","",$textarea);
BUT!!! When I look at the file, the line is written like this:
var text = "textM from form";
A VERY STRANGE M gets written to the file, and if I "echo" the $res variable before sending to the file, i dont see that M character.
I am trying with every PHP function useful for this (str_replace, nl2br, eregi_replace), but i ALWAYS get the same result in the file.... even replacing \n with \t or any other character....
EXCEPT when I replace \n with \n!! like this:
$res = ereg_replace("\n","\n",$textarea);
PLEASE!!! can someone tell me what is happening?
Thanks