Reputation: 6907
I have a string in PHP that contains both single and double quotes.
I am trying to use this string in some JSON output. To do this I need to escape double quotes, slashes, newlines etc.
I thought that addslashes() would do the job but it also escapes single quotes which causes the JSON to fail.
How can I escape all relevant special characters except for single quotes?
Upvotes: 0
Views: 2696