I want to replace every new line with " + "
in order to eliminate this problem. I'm only want to get the last data in the database, so I am using PHP to get the subject and the message for my saved blog post. This is working very fine but it outputs the data for the content of the blog post wrong.
In order to correct this, I must somehow replace every new line in my blog post with " + "
and what I can come think of is str_replace
but it will not change the new lines to what I want. Here is how I have done so far:
str_replace("/ /", '" + "', addslashes($saved_blogpost['data_message']))
How can I fix this?
Thanks in advance.
In reality you want to use json_encode()
, and not mess with the string.