Home > Article > Backend Development > How to get the json array data from the applet in php (code)
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:
php:
Tested Direct $_POST['Datas'] reception can be received but cannot be parsed
Later Baidu went to
$command = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input"); $command_decode = urldecode($command); parse_str($command_decode, $output); $photo_datas = json_decode($output['Datas'],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!