当我想从带有/
的json中回显数据时,它会在/
处加上反斜杠。
如何删除反斜杠?
此:
$data = [
"actualdir" => "uploads/aaa"
];
echo json_encode($data);
将此作为输出:
{"actualdir":"uploads\/aaa"}
应该是:
{"actualdir":"uploads/aaa"}
我该如何实现?
答案 0 :(得分:2)
对于<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<button id="btn-decrease">A-</button>
<button id="btn-orig">A</button>
<button id="btn-increase">A+</button>
<div id="bodytext">
<blockquote>
<h1 dir="ltr" align="center">
<span style="font-size: 35pt" lang="ar-sa">title page</span></h1>
<p class=MsoNormal dir=ltr style='text-align:justify'><b>
<font size="5">4. some text: " more text</font></b><font size="5"><span
lang=ar-eg> <b>more words</b></span><b>"</b></font><b><font size="5">[6].</font></b></p>
<p class=MsoNormal dir=ltr style='text-align:justify'>
<font size="5">new sentence..................</font>
<font style="font-size: 18pt" SIZE="5">
<a style="font-size:18pt;" href="http://example.com/file.html">a link</a></font><font size="5">texttexttext.......</font><font SIZE="5" face="Times New Roman">
<span lang="AR-EG" style="font-size: 18pt; ">
<a href="http://www.example.com/file.php">a link</a></span></font><font size="5">words words words words words ..</font></p>
<h2 dir=ltr> </h2>
<h2 dir=ltr><b><span style="font-size: 22pt; font-style: normal">
<a name="text">other text</a></span></b></h2>
<p class=MsoNormal dir=ltr style='text-align:justify'><b>
<font size="5">"final words....</font></b><font size="5"><b>"</b></font><b><font size="5">[7].</font></b></p>
</blockquote>
</div>
,您可以尝试使用JSON_UNESCAPED_SLASHES
选项-即:
json_encode
还有许多其他选项-请访问PHP.net
了解更多信息