首頁  >  文章  >  後端開發  >  php中如何得到小程式傳來的json陣列資料(程式碼)

php中如何得到小程式傳來的json陣列資料(程式碼)

不言
不言原創
2018-09-04 17:57:303604瀏覽

這篇文章帶給大家的內容是關於php中如何得到小程式傳來的json陣列資料(程式碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有幫助。

小程式:

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

小程式傳輸的資料:

php中如何得到小程式傳來的json陣列資料(程式碼)

php:

經過測試直接$_POST['Datas'] 接收 能接收到但是解析不出來

後來百度到

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

可百度查各函數的用法

相關建議:

php如何取得post 方式傳遞的json中的資料!

PHP中陣列轉換成json字串程式碼

#

以上是php中如何得到小程式傳來的json陣列資料(程式碼)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn