这篇文章主要介绍了PHP去掉json字符串中的反斜杠\及去掉双引号前的反斜杠的相关资料,需要的朋友可以参考下
通过AJAX传到PHP的json字符串有时候加上反斜杠”\”来转义,PHP处理时需要先去掉反斜杠,然后再json_decode.
$str = stripslashes($_POST['json']); $arr = json_decode($str,true);
PS:php get抓取json怎样去除双引号前面的反斜杠
你这个不算标准的JSON格式数据,可以先将\"替换成"即可。
再用json_decode()系统函数将其转为json对象,如需转为数组加上第二个参数为true即可。
若仍输出为NULL,是由于存在BOM头信息,
复制代码 代码如下:
$arr = json_decode(trim($json,chr(239).chr(187).chr(191)),true);
转换即可。
本文全部内容介绍完了,,希望对大家在使用PHP去掉json字符串中的反斜杠\及去掉双引号前的反斜杠中有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools
