Home  >  Article  >  Backend Development  >  How to remove json backslash in php

How to remove json backslash in php

藏色散人
藏色散人Original
2021-10-25 09:51:325466browse

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);

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!

Statement:
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