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)

不言
Release: 2023-04-04 06:24:01
Original
3650 people have browsed it

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);
Copy after login

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  为最终要的结果 */
Copy after login

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!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template