PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Fri Dec 15, 2006 8:36 am
$_SESSION be a 2-D array?
For example:
I'm sceptical at the moment as it's not containing a value once assigned.
Regards,
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Dec 15, 2006 8:42 am
Try it.
And seriously, use FAR MORE descriptive thread titles please.
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Fri Dec 15, 2006 8:48 am
That title wasn't intended.
Sorry either way.
dibyendrah
Forum Contributor
Posts: 491 Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:
Post
by dibyendrah » Fri Dec 15, 2006 11:24 am
I have never tried that with session. So, here goes the test :
Code: Select all
<?php
session_start();
$_SESSION[x][y][z] = 'xyz';
$_SESSION[a][b][c] = 'abc';
var_dump($_SESSION);
?>
Output :
Code: Select all
array(2) {
["x"]=>
array(1) {
["y"]=>
array(1) {
["z"]=>
string(3) "xyz"
}
}
["a"]=>
array(1) {
["b"]=>
array(1) {
["c"]=>
string(3) "abc"
}
}
}
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Fri Dec 15, 2006 2:50 pm
But for freaking crying out loud wrap your array indexes in quotes...
I like feyd's advice. Try it. Seriously, What is the worst that could happen? But for clean coding sake, this:
Code: Select all
<?php
session_start();
$_SESSION[x][y][z] = 'xyz';
$_SESSION[a][b][c] = 'abc';
var_dump($_SESSION);
?>
should be:
Code: Select all
<?php
session_start();
$_SESSION['x']['y']['z'] = 'xyz';
$_SESSION['a']['b']['c'] = 'abc';
var_dump($_SESSION);
?>
dibyendrah
Forum Contributor
Posts: 491 Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:
Post
by dibyendrah » Sun Dec 17, 2006 1:07 am
Thanks Everah for commenting. Yes I forgot to put quotes.
Output :
Code: Select all
array(2) {
["x"]=>
array(1) {
["y"]=>
array(1) {
["z"]=>
string(3) "xyz"
}
}
["a"]=>
array(1) {
["b"]=>
array(1) {
["c"]=>
string(3) "abc"
}
}
}
Thank you.