Escape JSON string
function escapeJsonString($value) {
return str_replace(
array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"),
array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"),
$value
);
}
Written by Ezequias Dinella
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#