Jump to content

array_sum() with multidimensional $_SESSION arrays


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?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.