php-general | 2001092
Date: 09/21/01
- Next message: Jeffrey Iskandar Ahmad: "[PHP] installing PHP with-apxs with-oci8 --with-oracle onLinux - remote oracle"
- Previous message: _lallous: "[PHP] Re: importing a text file"
- In reply to: Neil Freeman: "[PHP] Generating variable names 'on the fly'"
- Next in thread: Marcus Rasmussen: "Re: [PHP] Generating variable names 'on the fly'"
- Reply: Marcus Rasmussen: "Re: [PHP] Generating variable names 'on the fly'"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
you can always use eval to create a variable too!
<?
$i = 1;
eval("\$test$i=123;");
echo $test1;
?>
"Neil Freeman" <neil.freeman <email protected>> wrote in message
news:3BAA0EAA.BA5B2DBC <email protected>
> Hi there,
>
> How do I generate variable names 'on the fly'? I wish to have variable
> names along the lines of $genre_category_1, $genre_category_2,
> $genre_category_3 etc.
>
> Ideally it would be along the lines of this...
>
> #######################
> $current_field_number = 1;
> $genre_number_fields = 7;
>
> while ($current_field_number < $genre_number_fields)
> {
> //this var will change on every loop
> $genre_desc = $db_movies_genres->Record[$current_field_number];
>
> //something along the lines of...(you get the idea)
> $str_category = "genre_category_" . $current_field_number;
> $$str_category = $genre_desc;
>
> $current_field_number++;
> }
> #######################
>
> Any help would be greatly appreciated.
>
> Neil
> --------------------------------
> Email: neil.freeman <email protected>
> neil_freeman <email protected>
> --------------------------------
>
>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Jeffrey Iskandar Ahmad: "[PHP] installing PHP with-apxs with-oci8 --with-oracle onLinux - remote oracle"
- Previous message: _lallous: "[PHP] Re: importing a text file"
- In reply to: Neil Freeman: "[PHP] Generating variable names 'on the fly'"
- Next in thread: Marcus Rasmussen: "Re: [PHP] Generating variable names 'on the fly'"
- Reply: Marcus Rasmussen: "Re: [PHP] Generating variable names 'on the fly'"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

