printing from multidimensional arrays?
up vote
0
down vote
favorite
I have a multi array that looks like this:
$_SESSION['cartItems']['quantity']
How do I print out its values? print_r
won't work, unless $_SESSION
doesn't support multi-dimensional arrays?
php arrays
add a comment |
up vote
0
down vote
favorite
I have a multi array that looks like this:
$_SESSION['cartItems']['quantity']
How do I print out its values? print_r
won't work, unless $_SESSION
doesn't support multi-dimensional arrays?
php arrays
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a multi array that looks like this:
$_SESSION['cartItems']['quantity']
How do I print out its values? print_r
won't work, unless $_SESSION
doesn't support multi-dimensional arrays?
php arrays
I have a multi array that looks like this:
$_SESSION['cartItems']['quantity']
How do I print out its values? print_r
won't work, unless $_SESSION
doesn't support multi-dimensional arrays?
php arrays
php arrays
edited Nov 20 at 2:43
Cœur
17.2k9102141
17.2k9102141
asked May 4 '10 at 23:43
michael
1641310
1641310
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
0
down vote
print_r($_SESSION['cartItems']);
should work.
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
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']);
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
print_r($_SESSION['cartItems']);
should work.
add a comment |
up vote
0
down vote
print_r($_SESSION['cartItems']);
should work.
add a comment |
up vote
0
down vote
up vote
0
down vote
print_r($_SESSION['cartItems']);
should work.
print_r($_SESSION['cartItems']);
should work.
answered May 4 '10 at 23:46
nickf
368k171581687
368k171581687
add a comment |
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
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.
add a comment |
up vote
0
down vote
up vote
0
down vote
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.
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.
answered May 4 '10 at 23:47
Zak
16.2k103263
16.2k103263
add a comment |
add a comment |
up vote
0
down vote
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']);
add a comment |
up vote
0
down vote
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']);
add a comment |
up vote
0
down vote
up vote
0
down vote
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']);
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']);
answered May 4 '10 at 23:58
strager
71.9k19111164
71.9k19111164
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2769687%2fprinting-from-multidimensional-arrays%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown