Home >Backend Development >PHP Tutorial >How to get the json array data from the applet in php (code)

How to get the json array data from the applet in php (code)

不言
不言Original
2018-09-04 17:57:303683browse

The content of this article is about how to get the json array data (code) from the applet in php. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .

Mini program:

var Datas = [];
for (var i = 0; i < flise.length;i++){
    Datas.push([{ "img": flise[i] }, { "fapiao": fapiao[i]}]);
}
Datas = JSON.stringify(Datas);

Data transmitted by the mini program:

How to get the json array data from the applet in php (code)

php:

Tested Direct $_POST['Datas'] reception can be received but cannot be parsed

Later Baidu went to

$command =  isset($GLOBALS[&#39;HTTP_RAW_POST_DATA&#39;]) ? $GLOBALS[&#39;HTTP_RAW_POST_DATA&#39;] : file_get_contents("php://input");

$command_decode = urldecode($command);

parse_str($command_decode, $output);

$photo_datas = json_decode($output[&#39;Datas&#39;],true);

/*$photo_datas  为最终要的结果 */

You can check the usage of each function on Baidu

Related recommendations:

How does php get the data in json passed in post mode!

Program code for converting an array into a json string in PHP

The above is the detailed content of How to get the json array data from the applet in php (code). 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