Hi all,
Firstly, must say thanks to Sneakyimp for their help in my last thread to helping me come to a solution.
Right, next part of my adventure is totaling a quantity into one number of multiple orders.
For example, if user orders 7 of one item, 3 of another items and 9 of another the total qty for the order is 19 units.
I understand that count() will give me the number of array values within an array and COUNT_RECURSIVE will give me total number of values including array value.
So, if:
$a[] = 7;
$a[] = 3;
$a[] = 9;
$b = count($a); //would output 3?
$c = count($a, COUNT_RECURSIVE); //would output 6?
However, my script retrieves quantitys for items as seperate values within a for loop which I have consolodated into one array, which I've checked with is_array() function. But when I come to add them, I don't get the number I want...
Here is the chunk of code I'm using:
for ($i = 0; $i < $numItem; $i++) {
extract($cartContent[$i]);
$pd_name = "$ct_qty x $pd_name";
$url = "index.php?c=$cat_id&p=$pd_id";
$subTotal += $pd_price * $ct_qty;
$qtytotal[] = array($ct_qty);
} // end while
foreach ($qtytotal as $totqty){
print_r (count($totqty));
}
I've also tried without a foreach loop, but can't get my head around it.
It seems a simple enough task, but for now I can't quite get my head around it.
Thanks for looking