Re: Dynamic Multi Dimensional Arrays
| From: | Brad Pauly | Date: | Tue, 09 Sep 2003 16:46:52 +0000 |
| Subject: | Re: Dynamic Multi Dimensional Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162092@lists.php.net to get a copy of this message | ||
Bobby Patel wrote:
Hello Everyone, I want to emulate session objects (as opposed to variables). I stumbled upon creating multi-dimensional arrays, so I can do this: $name = 'Bob'; $year = '2003'; $HTTP_SESSION_VARS[$user][$year] = 'registered'; which gives $HTTP_SESSION_VARS['Bob']['2003'] = 'registered'; but I want to append an options array in this so what I want is: $options = array ( 'income' => 10000,There is, but I am not sure that is what you want. The reason you are getting the above result is because you are using $object (which is an array) as a key. Do you want an array element that holds the $options array? $HTTP_SESSION_VARS[$user]['options'] = $options; You could then add elements to this array like this: $HTTP_SESSION_VARS[$user]['options']['registered'] = 1; Is that what you are trying to do? - Brad'age' => 25 );$HTTP_SESSION_VARS[$user][$options] = 'registered'; which gives: $HTTP_SESSION_VARS['Bob'][ [income]=10000, [age]=25 ] = 'registered'; but this doesn't work. Is there any way I can have "objects" saved in sessions?