"Phil Schwarzmann" <[EMAIL PROTECTED]> wrote:

> Let's say I a variable called $var1 and it's values is "one"
> 
> ...I want to access them by doing something like this...
> 
> $i = 1;
> if ("var".$i == "one") echo "Hello!";
> 
> ...I want the combination of "var" and $i to equal $var1
> 
> How do I do this??
> The code I just wrote will not print out "Hello!"

You can use variable variable names by adding another '$'.
so if $i == 1 and $var1 == "one", you can do this:

$var_name = "var".$i;
if($$var_name == "one") echo "Hello!";

That should work,
Justin


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

Reply via email to