Re: Dynamic Multi Dimensional Arrays
| From: | Tom Rogers | Date: | Tue, 09 Sep 2003 16:45:21 +0000 |
| Subject: | Re: Dynamic Multi Dimensional Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162091@lists.php.net to get a copy of this message | ||
Hi,
Tuesday, September 9, 2003, 2:19:28 PM, you wrote:
BP> Hello Everyone,
BP> I want to emulate session objects (as opposed to variables). I stumbled
BP> upon creating multi-dimensional arrays, so I can do this:
BP> $name = 'Bob';
BP> $year = '2003';
BP> $HTTP_SESSION_VARS[$user][$year] = 'registered';
BP> which gives $HTTP_SESSION_VARS['Bob']['2003'] = 'registered';
BP> but I want to append an options array in this so what I want is:
BP> $options = array (
BP> 'income' => 10000,
BP> 'age' => 25
BP> );
BP> $HTTP_SESSION_VARS[$user][$options] = 'registered';
BP> which gives:
BP> $HTTP_SESSION_VARS['Bob'][ [income]=10000, [age]=25 ] = 'registered';
BP> but this doesn't work. Is there any way I can have "objects" saved in
BP> sessions?
BP> Bobby
you would have to give $user another key value
$options = array('income'=>10000.'age'=>25);
$HTTP_SESSION_VARS[$user] = $options;
$HTTP_SESSION_VARS[$user]['status'] = 'registered';
also in these cases print_r($HTTP_SESSION_VARS[$user]) can be your
friend.
--
regards,
Tom