Home > Backend Development > PHP Tutorial > 用session兑现购物车

用session兑现购物车

WBOY
Release: 2016-06-13 11:16:51
Original
955 people have browsed it

用session实现购物车
用session实现购物车,我是准备如果点放入购物车,则将一个商品的信息当成数组的一项插入$arr数组,
最后这个数组是一个二维数组,存放了所有购买的信息,
那么如果商品已经购买过,我怎么去判断并且只是将它的pdnum增加1,而不插入新项呢,
这段代码组织不来,谁帮忙下。。
$arr=array(array("pdname"=>"xx","pdprice"=>12,"pdnum"=>1),array("pdname"=>"yy","pdprice"=>22,"pdnum"=>1))
?>


------解决方案--------------------
为什么要用二维数组呢?
用一维的不是更简单吗?
商品名(或货号) => 数量
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