Home > Article > Backend Development > How to remove json backslash in php
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.
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!