So, I'm passing a value from php to javascript, the value originally is taken in from a form, is stored in mysql, and is pulled out by the php code to get passes to the javascript.
Here's my code:
$value2 = str_replace(array('"',"'", "\r", "\n", "\0", "<br />"), "", $value2);
$value2 = str_replace("\n","\\n",$value2);
$value2 = str_replace("\r","\\r",$value2);
echo "entries[$key][$key2] = '$value2';\n";
I'm getting an unterminated string contant error, and when I look at page source I see that the php has written a newline after $value2 and before the closing ';
What am I doing wrong in escaping newlines? Is there some other character I need to be escaping?
str_replace Question
Started by
Guest_Grouchotron_*
, Jul 28 2010 10:47 PM
1 reply to this topic
#1
Guest_Grouchotron_*
Posted 28 July 2010 - 10:47 PM
Guest_Grouchotron_*
|
|
|


Sign In
Create Account

Back to top









