Strip quotes in PHP for JSON output
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, newline开发者_StackOverflows 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?
json_encode()
will handle all that for you.
精彩评论