Re: passing arrays?
From: Al (php.newsgroups_at_allysays.com)
Date: 12/12/03
- Next message: Galen: "Re: [PHP] Palm OS Processor"
- Previous message: Motorpsychkill: "RE: [PHP] passing arrays?"
- In reply to: Motorpsychkill: "passing arrays?"
- Next in thread: Motorpsychkill: "RE: [PHP] Re: passing arrays?"
- Reply: Motorpsychkill: "RE: [PHP] Re: passing arrays?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: php-general@lists.php.net Date: Fri, 12 Dec 2003 17:28:21 +1100
> $level = '$level_' . $_SESSION['user']['level'];
> //Where $_SESSION['user']['level'] can equal "1" or "2"
>
> $level_1 = array("PN", "GALUP", "VP", "PUBUP", "STATS", "MCI", "CONLIST",
> "CP", "OAFS", "LO");
> $level_2 = array("PN", "GALUP", "VP", "PUBUP", "MCI", "CONLIST", "CP",
> "OAFS", "LO");
I can see two problems with your code:
1) The syntax for assigning to $level is wrong.
Rather than:
$level = '$level_' . $_SESSION['user']['level'];
your code should read:
$level = ${'level_' . $_SESSION['user']['level']};
For more information on this syntax, see:
http://us2.php.net/manual/en/language.variables.variable.php
2) You are assigning $level_1 or $level_2 (depending on the value of
$_SESSION['user']['level']) to $level *before* you have assigned $level_1 or
$level_2 any values. There's no point making $level = $level_1 if $level_1
hasn't been defined yet.
Working code would be:
$level_1 = array("PN", "GALUP", "VP", "PUBUP", "STATS", "MCI", "CONLIST",
"CP", "OAFS", "LO");
$level_2 = array("PN", "GALUP", "VP", "PUBUP", "MCI", "CONLIST", "CP",
"OAFS", "LO");
$level = ${'level_' . $_SESSION['user']['level']};
Hope it helps,
Al
- Next message: Galen: "Re: [PHP] Palm OS Processor"
- Previous message: Motorpsychkill: "RE: [PHP] passing arrays?"
- In reply to: Motorpsychkill: "passing arrays?"
- Next in thread: Motorpsychkill: "RE: [PHP] Re: passing arrays?"
- Reply: Motorpsychkill: "RE: [PHP] Re: passing arrays?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]