Jump to content

array_sum() with multidimensional $_SESSION arrays


vassili

Recommended Posts

i have this array $cartSizes[$productid] where $productid is an array of 8 values (1-8).  $cartSizes is  stored in a $_SESSION array like this

 

$_SESSION['cartSizes'] = $cartSizes;

 

an example of a $_SESSION['cartSizes'] array that has 2 $productid would be:

 

[cartSizes] => Array ( [8061ABL] => Array ( [1] => 0 [2] => 3 [3] => 4 [4] => 5 [5] => 0 [6] => 0 [7] => 0 [8] => 0 )[6105AAOAU] => Array ( [1] => 3 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 ) )

 

i want to get the sum of $_SESSION['cartSizes'].  but this doesn't work...i keep getting "0".

 

sum_array($_SESSION['cartSizes'])

 

what's wrong?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.