开发者

Making a variable out of another variables' value in php (php basics)

开发者 https://www.devze.com 2023-02-01 10:08 出处:网络
I need to make a dynamic variab开发者_JAVA百科le based on a loop, what i am looking for is a variable something like

I need to make a dynamic variab开发者_JAVA百科le based on a loop, what i am looking for is a variable something like

$var = "foo";

$$var = "bar";

echo $foo; // bar

but for me it should be more like a fixed parameter attached to the dynamic part like

$var='123';

$'current_'.$$var=some value; // not correct syntax

echo $current_123 should give 'some value';


Use curly braces:

$${'current_' . $var} = $some_value;
0

精彩评论

暂无评论...
验证码 换一张
取 消