How to remove json backslash in php

藏色散人
Release: 2023-03-13 13:20:02
Original
5254 people have browsed it

How to remove json backslashes in php: 1. Delete the backslashes through the "stripslashes($_POST['json']);" method; 2. Use "json_decode" to decode the JSON format string Just decode it.

How to remove json backslash in php

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

How to remove json backslash in php?

PHP removes the backslash in the json string\

The json string passed to PHP through AJAX is sometimes escaped with a backslash "\", PHP When processing, you need to remove the backslashes first, and then json_decode.

$str = stripslashes($_POST['json']);$arr = json_decode($str,true);
Copy after login

stripslashes() function: delete the backslashes added by the addslashes() function.

json_decode: Decode the string in JSON format.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to remove json backslash in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!