Re: session array
| From: | Stut | Date: | Mon, 07 Aug 2006 15:10:52 +0000 |
| Subject: | Re: session array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240261@lists.php.net to get a copy of this message | ||
Ross wrote:
I am creating an array of sessions $_SESSION['results'][] There may be up to 7 and I need to know why do I always get the notice'Undefined index: results in...'? How do I define or initialise the array if it only gets set once the form has been posted (an answer has been given) on the page. Is there a way to count/output (FOR EACH?) a set of session arrays like this?Before you try to access the $_SESSION['results'] array, do this... if (!isset($_SESSION['results'])) $_SESSION['results'] = array(); As far as counting and outputting a session array there is nothing special about them - they are the same as any other array variable. This means you can use foreach, print_r, var_dump, etc on them. -Stut