Re: Dynamic Variable names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's probably better to use arrays.

$tips[0] = "value";
$tips[1] = "value";
$tips[2] = "value";

Although, if you REALLY want dynamic variable names.

$i = 1;
$varname = 'tips_'.$i;
$$varname = "value";

this will make a variable like below:

$tips_1 = "value";

But like I said before, it's better to use arrays - they are much more flexible (and PHP arrays are especially cool).

http://www.php.net/manual/en/ref.array.php

adam

Just a quick question about dynamic variables

would like to end up with a variable called
$tips_1
$tips_2
...
$tips_n

where "n" is the value of the variable $sid

i have tried

$tips . '$sid';

and other variants, but i can't get one that doesn't return a parse error or T_VARIABLE error.

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux