Re: [PHP] A variable inside a variable?

2006-06-26 Thread Brad Bonkoski

This might help...
http://www.php.net/manual/en/function.array.php

-B

Alex Major wrote:


Thanks for your help with my other question, heres a new one for you.

I need to nest a variable, inside another variable. For example:

$($buildingname)level

How (if at all) is this possible?

Thanks.
Alex.

 



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



RE: [PHP] A variable inside a variable?

2006-06-26 Thread Jim Moseby
 
 Thanks for your help with my other question, heres a new one for you.
 
 I need to nest a variable, inside another variable. For example:
 
 $($buildingname)level
 
 How (if at all) is this possible?


http://us3.php.net/manual/en/language.variables.variable.php

JM

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



Re: [PHP] A variable inside a variable?

2006-06-26 Thread tg-php
I've never found a use for it myself, but yes.. php provides for 'variable 
variables':

http://us3.php.net/manual/en/language.variables.variable.php

$a = 'varname';
$varname = 'test';

echo $$a;

 test

-TG

= = = Original message = = =

Thanks for your help with my other question, heres a new one for you.

I need to nest a variable, inside another variable. For example:

$($buildingname)level

How (if at all) is this possible?

Thanks.
Alex.


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] A variable inside a variable?

2006-06-26 Thread Jochem Maas
Alex Major wrote:
 Thanks for your help with my other question, heres a new one for you.
 
 I need to nest a variable, inside another variable. For example:
 
 $($buildingname)level
 
 How (if at all) is this possible?

it's possible but probably an array is a better solution:

$someBuildinglevel = foo;
$buildingname = someBuilding;

echo ${$buildingname.level}; // outputs foo

now go lookup variable variables in the manual to for your penance ;-)

 
 Thanks.
 Alex.
 

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



RE: [PHP] A variable with a variable

2002-01-11 Thread Ford, Mike [LSS]

 -Original Message-
 From: Yoed [mailto:[EMAIL PROTECTED]]
 Sent: 10 January 2002 23:01
 
 I never really found the trick to this one yet, and wanted to 
 see what you
 guys say is the best methods to call a variable that needs a variable.
 
 Say I have variables called $Var_1_Stat, $Var_2_Stat, and $Var_3_Stat
 and I have a variable called $Nums thats value is either 1, 2, or 3.
 How then would I go about calling $Var_Call=$Var_$Num_Stat ? Or
 $Var_Call=$Var_$Num_State hmm not hat wouldn't work?
 So what do you guys suggest?

I suggest arrays -- is there a good reason why they won't do the job in this case?  If 
it were at all possible, I'd reformulate the algorithm using these variables so they 
could be $Var_Stat[$Nums] ($Var_Stat[1], $Var_Stat[2], etc.).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Fwd: Re: [PHP] A variable with a variable

2002-01-10 Thread [EMAIL PROTECTED]


Use:

$t = Var_ . $Num_State;
$Var_Call= $$t;

or:

$Var_Call= ${Var_ . $Num_State};


bvr.

On Thu, 10 Jan 2002 17:00:51 -0600, Yoed wrote:

I never really found the trick to this one yet, and wanted to see what you
guys say is the best methods to call a variable that needs a variable.

Say I have variables called $Var_1_Stat, $Var_2_Stat, and $Var_3_Stat
and I have a variable called $Nums thats value is either 1, 2, or 3.
How then would I go about calling $Var_Call=$Var_$Num_Stat ? Or
$Var_Call=$Var_$Num_State hmm not hat wouldn't work?
So what do you guys suggest?

No if statements... since I want to know a way that can be used if I have
more then just 3 or a limited ammount of varaibles.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] A variable with a variable

2002-01-10 Thread Martin Towell

you'll be wanting pointers

eg
$Var_1_Stat = hello world;
$Num = 1;
$var_name = Var_${Num}_Stat;  // set up the actual var name
$Var_Call = $$var_name; // now reference the actual var
echo $Var_Call; // should by hello world ...

:)

-Original Message-
From: Yoed [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 11, 2002 10:01 AM
To: [EMAIL PROTECTED]
Subject: [PHP] A variable with a variable


I never really found the trick to this one yet, and wanted to see what you
guys say is the best methods to call a variable that needs a variable.

Say I have variables called $Var_1_Stat, $Var_2_Stat, and $Var_3_Stat
and I have a variable called $Nums thats value is either 1, 2, or 3.
How then would I go about calling $Var_Call=$Var_$Num_Stat ? Or
$Var_Call=$Var_$Num_State hmm not hat wouldn't work?
So what do you guys suggest?

No if statements... since I want to know a way that can be used if I have
more then just 3 or a limited ammount of varaibles.

Thank you for your time,
Yoed



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]