Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question 开发者_运维百科Can someone please remind me how you call this type of variable
${'varname_'.$x}
Thanks!
It's called variable variables!
This should do it:
$varname = 'varname_'.$x;
echo $$varname;
variable varibales!!!
$var = "varname$x";
for($x=0;$x<10;$x++)
{
echo $$var;
}
edit ====
SHOULD BE:
for($x=0;$x<10;$x++)
{
$var = "varname$x";
echo $$var;
}
Variable variables. Your example could be used like so:
$varname_0 = 'Hello World!';
$x = 0;
echo ${'varname_'.$x}; // 'Hello World!'
精彩评论