NYCPHP Meetup

NYPHP.org

[nycphp-talk] accessing $_SESSION elements

Aaron Fischer agfische at email.smith.edu
Fri Oct 24 12:20:52 EDT 2003


Hi all,

I'm trying to avoid a bunch of if/then statements by looping through 
$_SESSION.  I hit a roadblock that I can't seem to get around.  Here is 
a simple piece of code which I think gets to the heart of the problem:

$begin=1;
if(isset($_SESSION['$begin_fair_name']))
{
   echo "success";
}

Of course, this works:
if(isset($_SESSION['$1_fair_name']))
{
   echo "success";
}

BUT, I have between 1 and 10 fair_name fields (i.e. 1_fair_name, 
2_fair_name) coming from the form.  It would be much more efficient if 
I can loop through and perform operations as opposed to a bunch of 
if/then statements referring to specific fair_name fields.  Obviously 
the problem is with using a variable inside the array and I haven't 
been able to figure out how to work around it.

Trying to keep it brief here, but please let me know if further details 
would be helpful.  I would appreciate any tips or suggestions.

Thanks!

-Aaron




More information about the talk mailing list