Re: session array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux