tags:

views:

24

answers:

3

i have a multi array that looks like this.

$_SESSION['cartItems']['quantity']

how do i print out its values? print_r wont work. unless i sessions dont work with multi arrays?

A: 

print_r($_SESSION['cartItems']); should work.

nickf
A: 

you can use var_dump($_SESSION). However, print_r should work. Make sure you are doing print_r($_SESSION), and not trying to print_r your variable that may not exist.

Zak
A: 

If you want to get the quantity of each card item in the array, you can do this:

$quantities = array_map(create_function('item', "$item['quanitity']"), $_SESSION['cardItems']);

// PHP 5.3
$quantities = array_map(function($item) {
    return $item['quanitity'];
}, $_SESSION['cardItems']);
strager