[nycphp-talk] accessing $_SESSION elements
Mark Armendariz
nyphp at enobrev.com
Fri Oct 24 12:33:22 EDT 2003
What about using an array as your session variable, and loop through the
array:
foreach($_SESSION['fair_name'] as $val) {
echo $val . ': success';
}
Mark
-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Aaron Fischer
Sent: Friday, October 24, 2003 12:21 PM
To: NYPHP Talk
Subject: [nycphp-talk] accessing $_SESSION elements
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
_______________________________________________
talk mailing list
talk at lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk
More information about the talk
mailing list