And even though it's much less elegant than the
solution by Sean below, you could also use 'eval'
$toast = array("wheat", "rye", "pumpernickel");
$numbreads = count($toast);
for ($index = 0; $index < $numbreads; $index++) {
eval("\$column$index = '$toast[$index]';
echo \$column$index . '<BR>';") ;
}
> -----Original Message-----
> From: Sean R. Bright [mailto:[EMAIL PROTECTED]]
> To: 'Jay Lepore'; [EMAIL PROTECTED]
> Subject: RE: [PHP] if $index=1 how can I create a variable named
>
> $toast = array("wheat", "rye", "pumpernickel");
> $numbreads = count($toast);
> for ($index = 0; $index < $numbreads; $index++) {
> ${"column" . $index} = $toasts[$index];
> }
>
> (A little less code and one less variable required.)
>
> Sean
--
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]