如何让php的json_encode不转义反斜杠

解决办法:

1. 正则替换

echo str_replace(“\\/”, “/”, json_encode(“2013/4/21”));
2. 若是php版本是5.4的话:

echo json_encode(“2011/7/11”, JSON_UNESCAPED_SLASHES);

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>