如何计算购物车数量? [英] How to count quantity in cart?
本文介绍了如何计算购物车数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
如何计算阵列的数量?请看例子。我通过一个例子更容易解释。
示例:
Hi!
How can I count the quantity of an array? Please see example. It is easier for me to explain through an example.
Example:
$_SESSION['products'] = array('123', '123', '456', '456', '456', '789', '789', '789', '789');
显示应为:
Display should be:
Item | Qty.
123 | 2
456 | 3
789 | 4
推荐答案
_SESSION [' products'] = array(' 123',' 123', 456',' 456', ' 456',' 789',' 789',' 789',' 789') ;
_SESSION['products'] = array('123', '123', '456', '456', '456', '789', '789', '789', '789');
显示应该是:
Display should be:
Item | Qty.
123 | 2
456 | 3
789 | 4
我会让你觉得很容易,这个技巧特别适用于php,以及你的数组有数值可以计算的事实。 br $>
计数:
I'll make it rather easy for you, a trick that works particularly well with php and the fact that your array has numerical values to count.
The counting:
countingStuff = NULL;
foreach(
countedStuff = NULL; foreach(
这篇关于如何计算购物车数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文