增加物品数量

main
pqjepwfgk 5 months ago
parent 998ee76485
commit 969acd2263

@ -0,0 +1,25 @@
<?php
$num_get = $_POST['num'];
$numb = json_decode($num_get,true);
var_dump($num_get);
$code="001";//动态数据
$json_string = file_get_contents("cart.json");// 从文件中读取数据到PHP变量
$data = json_decode($json_string,true);// 把JSON字符串转成PHP数组
$data["num"][$num_get]++;
$data["num"][$num_get] = (string)$data["num"][$num_get];
$json_strings = json_encode($data,JSON_UNESCAPED_UNICODE);
var_dump($data);
var_dump($json_string);
file_put_contents("cart.json",$json_strings);//写入
?>
Loading…
Cancel
Save