if $index=1 how can I create a variable named $column_1 by appending $index behind $columnname
| From: | Jay Lepore | Date: | Thu, 10 May 2001 01:09:22 +0000 |
| Subject: | if $index=1 how can I create a variable named $column_1 by appending $index behind $columnname | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-52210@lists.php.net to get a copy of this message | ||
I would like to loop through an array and create variable names such as
column1, column2, column3 etc. where the number at the end comes from the
value of index.
For instance:
1) $toast=array("wheat", "rye", "pumpernickel");
2) $numbreads=count($toast);
3) for($index=0;$index<$numbreads;$index++){
4) $column$index=$toasts[$index];
5) }
At the end I would in theory have three fields called column1, column2,
column3.
How can I append $index to another to make a new variable name as shown in
line 4 ?
Thanks in advance
Jay