从没有换行的数据库中获取文本值以使用它javascript变量[复制]

This question already has an answer here:

I have some text in my database and I want get it to store in javascript variable but because of data has linebreak thay doesn't store in variable can you help me?(sorry for my bad english!) for example my text in database is:

a
b
c
.
.
.
</div>

To create a Javascript literal from a PHP variable, use json_encode(). It will translate the line breaks to escape sequences.

var js_variable = <?php echo json_encode($php_variable); ?>;