2006/6/18, Peter Lauri <[EMAIL PROTECTED]>:

Best group member,



I have a variable $content that is taken from a database. It contains line
breaks and the $content will be posted with line breaks.



I need to use this to insert this into a JavaScript function:



$output = 'writeRichText(\'rte1\', \''.$content.'\', 400, 200, true,
false);';



What is actually outputted is:



writeRichText('rte1', '<p>a</p>

<h2>b</h2>', 400, 200, true, false);



Because it is on different lines in the HTML the javascript function will
not be called correct.



So can I remove all line breaks in a variable with a function call?



Dream: $content = stripLineBreaks($content);



I read the manual, but without luck.



Thanks in advance.



Check out http://php.net/addcslashes
maybe that will do the trick. If that doesn't work, you should try to
replace the line break character with the corresponding escape sequence.

Reply via email to