Try this:

$var_1 = "one";
$var_2 = "two";
$var_3 = "three";

for($i=1; $i<4; $i++)
{
 echo"$i. ";
 echo ${var_ . $i};
 echo" <br>";
}


----- Original Message ----- 
From: "Mize, Robert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 15, 2001 9:32 AM
Subject: [PHP-WIN] php3 var question


> If I have a set of variables named say:
> $var_1
> $var_2
> $var_3
> 
> and I want to use a for loop to do something with the variables like:
> for($i=1; $i<4; $i++){
>   echo $var_$i;
> }
> 
> how do I do this so that $var_$i is interpreted as the variable ($var_1
> ect)?
> 
> Thanks,
> rob.
> 
> 
> -- 
> PHP Windows 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]
> 
> 


-- 
PHP Windows 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]

Reply via email to