Re: Get rid of line breaks
| From: | Martin Alterisio | Date: | Sun, 18 Jun 2006 21:57:20 +0000 |
| Subject: | Re: Get rid of line breaks | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238243@lists.php.net to get a copy of this message | ||
2006/6/18, Peter Lauri <lists@dwsasia.com>:
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/addcslashesmaybe that will do the trick. If that doesn't work, you should try to replace the line break character with the corresponding escape sequence.