OTECTED]]
> Sent: Thursday, May 10, 2001 5:07 PM
> To: Php-General
> Subject: RE: [PHP] if $index=1 how can I create a variable named
> $column_1
>
>
> And even though it's much less elegant than the
> solution by Sean below, you could also use 'eval'
>
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
Strike that...I didn't read the question properly
Paul Kozlenko
"Paul Kozlenko" <[EMAIL PROTECTED]> wrote in message
9dd14a$gka$[EMAIL PROTECTED]">news:9dd14a$gka$[EMAIL PROTECTED]...
> How about;
>
> list($column1, $column2, $column3) = array("wheat2", "rye2",
> "pumpernickel2");
>
> Not totaly
How about;
list($column1, $column2, $column3) = array("wheat2", "rye2",
"pumpernickel2");
Not totaly flexible as below. But it satisfies the question. Needs php4.
Paul Kozlenko
"Jay Lepore" <[EMAIL PROTECTED]> wrote in message
9dcp7h$tjr$[EMAIL PROTECTED]">news:9dcp7h$tjr$[EMAIL PROTECTED]...
e required.)
Sean
> -Original Message-
> From: Sean R. Bright [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 09, 2001 9:49 PM
> To: 'Jay Lepore'; [EMAIL PROTECTED]
> Subject: RE: [PHP] if $index=1 how can I create a variable named
> $column_1 by appending $index beh
$toast = array("wheat", "rye", "pumpernickel");
$numbreads = count($toast);
for ($index = 0; $index < $numbreads; $index++) {
$temp = "column$index";
$$temp = $toasts[$index]
}
You will now have variables called column1, column2, and column3.
Sean
> -Original Message-
>
6 matches
Mail list logo