Re: [PHP] generating variable names

2002-09-08 Thread timo stamm

Hi Kevin,


I find it a bit awkward to mix variables and arrays in a pseudo 
array. But I guess you have reasons...

Anyhow, maybe this is what you want:


$variable1=one;
$variable2=two;
$variable3 = array();
$variable3[0]=three;
$variable4 = array();
$variable4[0]=four;

$j=1;
while($j5){
if (is_array(${variable.$j})) {
print(${variable.$j}[0] . br /);
} else {
print(${variable.$j} . br /);
};
$j++;
}


Timo


Am Freitag den, 6. September 2002, um 20:37, schrieb Kevin Heflin:

 Hoping someone can help me with this. Below I have an example 
 of what I'm trying to accomplish.
 Bottom line.. I need to print out $variable3[0] and $variable4[0]
 and my problem is that I'm trying to generate the variable 
 name. I can get this to work with $variable1 and $variable2 
 which are not arrays, however that doesn't help me much.

 Any suggestions would be appreciated.

 Kevin



 ?
   $variable1=one;
   $variable2=two;
   $variable3[0]=three;
   $variable4[0]=four;
   
   $j=1;
   while($j5){
   print(${variable.$j} BR);
   $j++;
   }


   $j=1;
   while($j5){
   $k=\$variable.$j.[0];
   print($k BR);
   print(${variable.$k} BR);
   $j++;
   }
 ?


 -- PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] generating variable names

2002-09-06 Thread Kevin Heflin

Hoping someone can help me with this. Below I have an example of what 
I'm trying to accomplish.
Bottom line.. I need to print out $variable3[0] and $variable4[0]
and my problem is that I'm trying to generate the variable name. I can 
get this to work with $variable1 and $variable2 which are not arrays, 
however that doesn't help me much.

Any suggestions would be appreciated.

Kevin



?
$variable1=one;
$variable2=two;
$variable3[0]=three;
$variable4[0]=four;

$j=1;
while($j5){
print(${variable.$j} BR);
$j++;
}


$j=1;
while($j5){
$k=\$variable.$j.[0];
print($k BR);
print(${variable.$k} BR);
$j++;
}
?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] generating variable names

2002-09-06 Thread Daniel Masson

Hi ... You can make it like this:

If you have 
$variable4[0]=four;

Then you can have a new variable

$$variable[0] , and the new variable´s name is four


Cordialmente

Daniel Massón = Ingeniero de desarollo

[EMAIL PROTECTED]

www.imagine.com.co

Tels: (57)(1) 2182064 - 6163218

Bogotá - Colombia



- Soluciones web para internet e intranet

- Asesoría y Soporte Técnico

- Licenciamiento de Software 



-Mensaje original-
De: Kevin Heflin [mailto:[EMAIL PROTECTED]] 
Enviado el: viernes, 06 de septiembre de 2002 13:38
Para: php-general
Asunto: [PHP] generating variable names


Hoping someone can help me with this. Below I have an example of what 
I'm trying to accomplish.
Bottom line.. I need to print out $variable3[0] and $variable4[0] and my
problem is that I'm trying to generate the variable name. I can 
get this to work with $variable1 and $variable2 which are not arrays, 
however that doesn't help me much.

Any suggestions would be appreciated.

Kevin



?
$variable1=one;
$variable2=two;
$variable3[0]=three;
$variable4[0]=four;

$j=1;
while($j5){
print(${variable.$j} BR);
$j++;
}


$j=1;
while($j5){
$k=\$variable.$j.[0];
print($k BR);
print(${variable.$k} BR);
$j++;
}
?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Generating variable names 'on the fly'

2001-09-21 Thread Marcus Rasmussen

You can allso do like this:

$i = 1;
${test. $i} = 123;
echo $test1;
___
Marcus Rasmussen
[EMAIL PROTECTED]

On 21-09-01 at 11:21 _lallous wrote:

you can always use eval to create a variable too!

?
$i = 1;
eval(\$test$i=123;);
echo $test1;
?

Neil Freeman [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[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:  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
 





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




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




[PHP] Generating variable names 'on the fly'

2001-09-20 Thread Neil Freeman

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:  [EMAIL PROTECTED]
 [EMAIL PROTECTED]